Skip to content

Commit bda6e82

Browse files
dschogitster
authored andcommitted
receive-pack: plug memory leak in update()
Reported via Coverity. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1efb1e9 commit bda6e82

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/receive-pack.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
986986
{
987987
const char *name = cmd->ref_name;
988988
struct strbuf namespaced_name_buf = STRBUF_INIT;
989-
const char *namespaced_name, *ret;
989+
static char *namespaced_name;
990+
const char *ret;
990991
struct object_id *old_oid = &cmd->old_oid;
991992
struct object_id *new_oid = &cmd->new_oid;
992993

@@ -997,6 +998,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
997998
}
998999

9991000
strbuf_addf(&namespaced_name_buf, "%s%s", get_git_namespace(), name);
1001+
free(namespaced_name);
10001002
namespaced_name = strbuf_detach(&namespaced_name_buf, NULL);
10011003

10021004
if (is_ref_checked_out(namespaced_name)) {

0 commit comments

Comments
 (0)