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>
Johannes Schindelin committed
May 4, 2017 at 15:57 UTC
bda6e82801e3c01d51634e6c722783295fd079ae
1 file changed
+3
-1
builtin/receive-pack.c
+3
-1
@@ -986,7 +986,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
986
{
987
const char *name = cmd->ref_name;
988
struct strbuf namespaced_name_buf = STRBUF_INIT;
989
- const char *namespaced_name, *ret;
989
+ static char *namespaced_name;
990
+ const char *ret;
991
struct object_id *old_oid = &cmd->old_oid;
992
struct object_id *new_oid = &cmd->new_oid;
993
@@ -997,6 +998,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
998
}
999
1000
strbuf_addf(&namespaced_name_buf, "%s%s", get_git_namespace(), name);
1001
+ free(namespaced_name);
1002
namespaced_name = strbuf_detach(&namespaced_name_buf, NULL);
1003
1004
if (is_ref_checked_out(namespaced_name)) {