Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2023-10-31 11:16:21 +0300
committerJunio C Hamano <gitster@pobox.com>2023-11-01 06:09:00 +0300
commitdbabd0b023b6a65267fd57ed04ecd47ac34b5ae5 (patch)
tree4738583fc6d0114f840f7960360d627a0cc3a0a7 /builtin/show-ref.c
parentb14cbae2b528ea8eda7e05febff9c395b8e5c968 (diff)
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/show-ref.c')
-rw-r--r--builtin/show-ref.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index cad5b8b506..e55c38af47 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -106,7 +106,7 @@ static int add_existing(const char *refname,
*/
static int cmd_show_ref__exclude_existing(const char *match)
{
- static struct string_list existing_refs = STRING_LIST_INIT_DUP;
+ struct string_list existing_refs = STRING_LIST_INIT_DUP;
char buf[1024];
int matchlen = match ? strlen(match) : 0;
@@ -139,6 +139,8 @@ static int cmd_show_ref__exclude_existing(const char *match)
printf("%s\n", buf);
}
}
+
+ string_list_clear(&existing_refs, 0);
return 0;
}