@matheusbsbs / matheus-bagliano / commits / 79bc2af5ae
Fork 0

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 <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Oct 2, 2010 at 03:41 UTC 79bc2af5ae161d1e81b57313c81fb81e3ec6c57d
1 file changed +7 -5
builtin/commit-tree.c
+7 -5
@@ -56,10 +56,12 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
56 if (strbuf_read(&buffer, 0, 0) < 0)
57 die_errno("git commit-tree: failed to read");
58
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);
61 return 1;
62 + }
63 +
64 + printf("%s\n", sha1_to_hex(commit_sha1));
65 + strbuf_release(&buffer);
66 + return 0;
67 }