Commit b0b3b4e39e372c29af6782bdee8ec1a87ff662dd

nulltoken 2012-05-29T16:19:15

treebuilder: prevent git_treebuilder_free() from segfaulting when being passed a NULL treebuilder

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/tree.c b/src/tree.c
index 92b1b1e..9283a1a 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -634,6 +634,9 @@ void git_treebuilder_clear(git_treebuilder *bld)
 
 void git_treebuilder_free(git_treebuilder *bld)
 {
+	if (bld == NULL)
+		return;
+
 	git_treebuilder_clear(bld);
 	git_vector_free(&bld->entries);
 	git__free(bld);