Skip to content

Commit 28db756

Browse files
jrngitster
authored andcommitted
revert: fix tiny memory leak in cherry-pick --ff
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8e75abf commit 28db756

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin-revert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
274274
int i, index_fd, clean;
275275
char *oneline, *reencoded_message = NULL;
276276
const char *message, *encoding;
277-
char *defmsg = git_pathdup("MERGE_MSG");
277+
char *defmsg = NULL;
278278
struct merge_options o;
279279
struct tree *result, *next_tree, *base_tree, *head_tree;
280280
static struct lock_file index_lock;
@@ -364,6 +364,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
364364
* reverse of it if we are revert.
365365
*/
366366

367+
defmsg = git_pathdup("MERGE_MSG");
367368
msg_fd = hold_lock_file_for_update(&msg_file, defmsg,
368369
LOCK_DIE_ON_ERROR);
369370

0 commit comments

Comments
 (0)