]> git.neil.brown.name Git - git.git/commitdiff
am: fix commit buffer leak in get_commit_info()
authorJeff King <peff@peff.net>
Thu, 27 Apr 2017 03:25:55 +0000 (23:25 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Apr 2017 05:38:50 +0000 (14:38 +0900)
Calling logmsg_reencode() may allocate a buffer for the
commit message (because we need to load it from disk, or
because it needs re-encoded). We must "unuse" it afterwards
to free it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c

index 826f18ba12d9c58ceb3e8d6998412c234b33bcfe..8dfe8f84fa461dd37850fecebcfe5a6943f789b3 100644 (file)
@@ -1417,6 +1417,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
                die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
        state->msg = xstrdup(msg + 2);
        state->msg_len = strlen(state->msg);
+       unuse_commit_buffer(commit, buffer);
 }
 
 /**