Skip to content

Commit

Permalink
merge: small leakfix and code simplification
Browse files Browse the repository at this point in the history
When parsing a merged object name like "foo~20" to formulate a merge
summary "Merge branch foo (early part)", a temporary strbuf is used,
but we forgot to deallocate it when we failed to find the named
branch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Apr 29, 2015
1 parent eaa4e59 commit 1016658
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
}
if (len) {
struct strbuf truname = STRBUF_INIT;
strbuf_addstr(&truname, "refs/heads/");
strbuf_addstr(&truname, remote);
strbuf_addf(&truname, "refs/heads/%s", remote);
strbuf_setlen(&truname, truname.len - len);
if (ref_exists(truname.buf)) {
strbuf_addf(msg,
Expand All @@ -503,6 +502,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
strbuf_release(&truname);
goto cleanup;
}
strbuf_release(&truname);
}

if (!strcmp(remote, "FETCH_HEAD") &&
Expand Down

0 comments on commit 1016658

Please sign in to comment.