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 <gitster@pobox.com>
This commit is contained in:
@ -491,8 +491,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
|
|||||||
}
|
}
|
||||||
if (len) {
|
if (len) {
|
||||||
struct strbuf truname = STRBUF_INIT;
|
struct strbuf truname = STRBUF_INIT;
|
||||||
strbuf_addstr(&truname, "refs/heads/");
|
strbuf_addf(&truname, "refs/heads/%s", remote);
|
||||||
strbuf_addstr(&truname, remote);
|
|
||||||
strbuf_setlen(&truname, truname.len - len);
|
strbuf_setlen(&truname, truname.len - len);
|
||||||
if (ref_exists(truname.buf)) {
|
if (ref_exists(truname.buf)) {
|
||||||
strbuf_addf(msg,
|
strbuf_addf(msg,
|
||||||
@ -503,6 +502,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
|
|||||||
strbuf_release(&truname);
|
strbuf_release(&truname);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
strbuf_release(&truname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(remote, "FETCH_HEAD") &&
|
if (!strcmp(remote, "FETCH_HEAD") &&
|
||||||
|
Reference in New Issue
Block a user