Jelajahi Sumber

fix tsearch to avoid crash on oom

malloc failure was not properly propagated in the insertion method
which led to null pointer dereference.
Szabolcs Nagy 9 tahun lalu
induk
melakukan
bc9744763a
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      src/search/tsearch_avl.c

+ 1 - 1
src/search/tsearch_avl.c

@@ -89,8 +89,8 @@ static struct node *insert(struct node **n, const void *k,
 			r->key = k;
 			r->left = r->right = 0;
 			r->height = 1;
+			*new = 1;
 		}
-		*new = 1;
 		return r;
 	}
 	c = cmp(k, r->key);