Skip to content

Commit 1016658

Browse files
committed
merge: small leakfix and code simplification
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 <[email protected]>
1 parent eaa4e59 commit 1016658

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin/merge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
491491
}
492492
if (len) {
493493
struct strbuf truname = STRBUF_INIT;
494-
strbuf_addstr(&truname, "refs/heads/");
495-
strbuf_addstr(&truname, remote);
494+
strbuf_addf(&truname, "refs/heads/%s", remote);
496495
strbuf_setlen(&truname, truname.len - len);
497496
if (ref_exists(truname.buf)) {
498497
strbuf_addf(msg,
@@ -503,6 +502,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
503502
strbuf_release(&truname);
504503
goto cleanup;
505504
}
505+
strbuf_release(&truname);
506506
}
507507

508508
if (!strcmp(remote, "FETCH_HEAD") &&

0 commit comments

Comments
 (0)