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 <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Mar 20, 2010 at 21:01 UTC
28db756feead84929cdfaaee8bccd301384daab4
1 file changed
+2
-1
builtin-revert.c
+2
-1
@@ -274,7 +274,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
274
int i, index_fd, clean;
275
char *oneline, *reencoded_message = NULL;
276
const char *message, *encoding;
277
- char *defmsg = git_pathdup("MERGE_MSG");
277
+ char *defmsg = NULL;
278
struct merge_options o;
279
struct tree *result, *next_tree, *base_tree, *head_tree;
280
static struct lock_file index_lock;
@@ -364,6 +364,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
364
* reverse of it if we are revert.
365
*/
366
367
+ defmsg = git_pathdup("MERGE_MSG");
368
msg_fd = hold_lock_file_for_update(&msg_file, defmsg,
369
LOCK_DIE_ON_ERROR);
370