]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/show-ref: fix leaking string buffer
authorPatrick Steinhardt <ps@pks.im>
Tue, 31 Oct 2023 08:16:21 +0000 (09:16 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Nov 2023 03:09:00 +0000 (12:09 +0900)
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>
builtin/show-ref.c

index cad5b8b5066b67725929977db116e931ff58a66a..e55c38af478bb7e0706809275b15dedf2b6d2e37 100644 (file)
@@ -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;
 }