소스 검색

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 년 전
부모
커밋
bc9744763a
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  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);