]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch-pack: free object filter before exiting
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 21:52:07 +0000 (17:52 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:24:53 +0000 (10:24 -0700)
Our fetch_pack_args holds a filter_options struct that may be populated
with allocated strings by the by the "--filter" command-line option. We
must free it before exiting to avoid a leak when the program exits.

The usual fetch code paths that use transport.c don't have the same
leak, because we do the cleanup in disconnect_git().

Fixing this leak lets us mark t5500 as leak-free.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch-pack.c
t/t5500-fetch-pack.sh

index c5319232a517c9619f82cfb78972c20e83d4aa2b..cfc6951d2399880a6e98750cbafb98bab0d667a2 100644 (file)
@@ -293,5 +293,6 @@ int cmd_fetch_pack(int argc,
        free(sought);
        free_refs(fetched_refs);
        free_refs(remote_refs);
+       list_objects_filter_release(&args.filter_options);
        return ret;
 }
index 585ea0ee1683193a6dd43a58c6b8f42c046b67e7..605f17240c191a0db573096c82638934a6ae0868 100755 (executable)
@@ -8,6 +8,7 @@ test_description='Testing multi_ack pack fetching'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # Test fetch-pack/upload-pack pair.