summaryrefslogtreecommitdiff
path: root/builtin/receive-pack.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2017-05-04 13:57:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-08 03:18:20 (GMT)
commitbda6e82801e3c01d51634e6c722783295fd079ae (patch)
tree3a282848f0520cb2959145e9a5404155707071fc /builtin/receive-pack.c
parent1efb1e9a21d16efddd1440bd2684bf19dc9546e0 (diff)
downloadgit-bda6e82801e3c01d51634e6c722783295fd079ae.zip
git-bda6e82801e3c01d51634e6c722783295fd079ae.tar.gz
git-bda6e82801e3c01d51634e6c722783295fd079ae.tar.bz2
receive-pack: plug memory leak in update()
Reported via Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r--builtin/receive-pack.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index f96834f..48c07dd 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -986,7 +986,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
{
const char *name = cmd->ref_name;
struct strbuf namespaced_name_buf = STRBUF_INIT;
- const char *namespaced_name, *ret;
+ static char *namespaced_name;
+ const char *ret;
struct object_id *old_oid = &cmd->old_oid;
struct object_id *new_oid = &cmd->new_oid;
@@ -997,6 +998,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
}
strbuf_addf(&namespaced_name_buf, "%s%s", get_git_namespace(), name);
+ free(namespaced_name);
namespaced_name = strbuf_detach(&namespaced_name_buf, NULL);
if (is_ref_checked_out(namespaced_name)) {