summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-07-24 04:41:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-07-24 20:57:49 (GMT)
commit28b3563241ac13733781fb0bada37f776a39f43d (patch)
treecd78612af838e155c552b5ea5a10fe691e627e6d /builtin
parentd51428bf17e9f17071836350299e256cac2d503a (diff)
downloadgit-28b3563241ac13733781fb0bada37f776a39f43d.zip
git-28b3563241ac13733781fb0bada37f776a39f43d.tar.gz
git-28b3563241ac13733781fb0bada37f776a39f43d.tar.bz2
free ref string returned by dwim_ref
A call to "dwim_ref(name, len, flags, &ref)" will allocate a new string in "ref" to return the exact ref we found. We do not consistently free it in all code paths, leading to small leaks. The worst is in get_sha1_basic, which may be called many times (e.g., by "cat-file --batch"), though it is relatively unlikely, as it only triggers on a bogus reflog specification. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/rev-parse.c1
-rw-r--r--builtin/show-branch.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 1a6122d..0bce2a6 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -150,6 +150,7 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
error("refname '%s' is ambiguous", name);
break;
}
+ free(full);
} else {
show_with_type(type, name);
}
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index d873172..b293090 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -779,6 +779,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
sprintf(nth_desc, "%s@{%d}", *av, base+i);
append_ref(nth_desc, sha1, 1);
}
+ free(ref);
}
else if (all_heads + all_remotes)
snarf_refs(all_heads, all_remotes);