Skip to content

Commit

Permalink
revert: fix tiny memory leak in cherry-pick --ff
Browse files Browse the repository at this point in the history
We forgot to free defmsg when returning early for a fast-forward.

Fixing this should reduce noise during test suite runs with valgrind.
More importantly, once cherry-pick learns to pick multiple commits,
the amount of memory leaked would start to add up.

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 Mar 21, 2010
1 parent 8e75abf commit 28db756
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin-revert.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
int i, index_fd, clean;
char *oneline, *reencoded_message = NULL;
const char *message, *encoding;
char *defmsg = git_pathdup("MERGE_MSG");
char *defmsg = NULL;
struct merge_options o;
struct tree *result, *next_tree, *base_tree, *head_tree;
static struct lock_file index_lock;
Expand Down Expand Up @@ -364,6 +364,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
* reverse of it if we are revert.
*/

defmsg = git_pathdup("MERGE_MSG");
msg_fd = hold_lock_file_for_update(&msg_file, defmsg,
LOCK_DIE_ON_ERROR);

Expand Down

0 comments on commit 28db756

Please sign in to comment.