summaryrefslogtreecommitdiff
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-04-23 21:37:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-04-29 20:17:52 (GMT)
commit1016658de3fe213eedebdb478cca0324ac8fbe87 (patch)
tree7f90a29f3f77684906fdbf81f26bfdd0a6cca41a /builtin/merge.c
parenteaa4e59c8545f61c6e61559df33dc4792e455d5a (diff)
downloadgit-1016658de3fe213eedebdb478cca0324ac8fbe87.zip
git-1016658de3fe213eedebdb478cca0324ac8fbe87.tar.gz
git-1016658de3fe213eedebdb478cca0324ac8fbe87.tar.bz2
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>
Diffstat (limited to 'builtin/merge.c')
-rw-r--r--builtin/merge.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 1d4fbd3..b2d0332 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -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,
@@ -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") &&