Skip to content

Commit

Permalink
commit-tree: free commit message before exiting
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Oct 7, 2010
1 parent c752e7f commit 79bc2af
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions builtin/commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
if (strbuf_read(&buffer, 0, 0) < 0)
die_errno("git commit-tree: failed to read");

if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) {
printf("%s\n", sha1_to_hex(commit_sha1));
return 0;
}
else
if (commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) {
strbuf_release(&buffer);
return 1;
}

printf("%s\n", sha1_to_hex(commit_sha1));
strbuf_release(&buffer);
return 0;
}

0 comments on commit 79bc2af

Please sign in to comment.