Skip to content

Commit 79bc2af

Browse files
jrngitster
authored andcommitted
commit-tree: free commit message before exiting
This buffer is freed by the C runtime when commit-tree exits moments later, but freeing it explicitly should make valgrind quieter. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c752e7f commit 79bc2af

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

builtin/commit-tree.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
5656
if (strbuf_read(&buffer, 0, 0) < 0)
5757
die_errno("git commit-tree: failed to read");
5858

59-
if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) {
60-
printf("%s\n", sha1_to_hex(commit_sha1));
61-
return 0;
62-
}
63-
else
59+
if (commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) {
60+
strbuf_release(&buffer);
6461
return 1;
62+
}
63+
64+
printf("%s\n", sha1_to_hex(commit_sha1));
65+
strbuf_release(&buffer);
66+
return 0;
6567
}

0 commit comments

Comments
 (0)