Skip to content

Commit dbabd0b

Browse files
pks-tgitster
authored andcommitted
builtin/show-ref: fix leaking string buffer
Fix a leaking string buffer in `git show-ref --exclude-existing`. While the buffer is technically not leaking because its variable is declared as static, there is no inherent reason why it should be. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b14cbae commit dbabd0b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/show-ref.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int add_existing(const char *refname,
106106
*/
107107
static int cmd_show_ref__exclude_existing(const char *match)
108108
{
109-
static struct string_list existing_refs = STRING_LIST_INIT_DUP;
109+
struct string_list existing_refs = STRING_LIST_INIT_DUP;
110110
char buf[1024];
111111
int matchlen = match ? strlen(match) : 0;
112112

@@ -139,6 +139,8 @@ static int cmd_show_ref__exclude_existing(const char *match)
139139
printf("%s\n", buf);
140140
}
141141
}
142+
143+
string_list_clear(&existing_refs, 0);
142144
return 0;
143145
}
144146

0 commit comments

Comments
 (0)