fetch-pack: free object filter before exiting

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>

Jeff King committed Sep 24, 2024 at 17:52 UTC 0c23f1a9e40038296e5479bedaf27d93f9fdba6a
2 files changed +2
builtin/fetch-pack.c
+1
@@ -293,5 +293,6 @@ int cmd_fetch_pack(int argc,
293 free(sought);
294 free_refs(fetched_refs);
295 free_refs(remote_refs);
296 + list_objects_filter_release(&args.filter_options);
297 return ret;
298 }
t/t5500-fetch-pack.sh
+1
@@ -8,6 +8,7 @@ test_description='Testing multi_ack pack fetching'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
11 +TEST_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
13
14 # Test fetch-pack/upload-pack pair.