From 966fb207021830819aad9fce098b4a63838def4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Wed, 25 Jun 2014 21:25:44 +0200 Subject: [PATCH] tree: free in error conditions As reported by coverity, we would leak some memory in error conditions. --- src/tree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tree.c b/src/tree.c index e0e2dbebf..28190d6da 100644 --- a/src/tree.c +++ b/src/tree.c @@ -466,6 +466,7 @@ static int append_entry( git_strmap_insert(bld->map, entry->filename, entry, error); if (error < 0) { + git_tree_entry_free(entry); giterr_set(GITERR_TREE, "failed to append entry %s to the tree builder", filename); return -1; } @@ -622,6 +623,7 @@ int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source) GITERR_CHECK_ALLOC(bld); if (git_strmap_alloc(&bld->map) < 0) { + git__free(bld); return -1; }