]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch-pack, send-pack: clean up shallow oid array
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 21:52:25 +0000 (17:52 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:24:53 +0000 (10:24 -0700)
When we call get_remote_heads() for protocol v0, that may populate the
"shallow" oid_array, which must be cleaned up to avoid a leak at the
program exit. The same problem exists for both fetch-pack and send-pack,
but not for the usual transport.c code paths, since we already do this
cleanup in disconnect_git().

Fixing this lets us mark t5542 as leak-free for the send-pack side, but
fetch-pack will need some more fixes before we can do the same for
t5539.

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

index cfc6951d2399880a6e98750cbafb98bab0d667a2..ef4143eef3c43fe444b229dc8322975259a74951 100644 (file)
@@ -294,5 +294,6 @@ int cmd_fetch_pack(int argc,
        free_refs(fetched_refs);
        free_refs(remote_refs);
        list_objects_filter_release(&args.filter_options);
+       oid_array_clear(&shallow);
        return ret;
 }
index 81fc96d423afd71da37cc4a3a10a80de4ca9c85b..c49fe6c53cc8ad3033181dabad7b97cccb0f2d7e 100644 (file)
@@ -343,5 +343,6 @@ int cmd_send_pack(int argc,
        free_refs(remote_refs);
        free_refs(local_refs);
        refspec_clear(&rs);
+       oid_array_clear(&shallow);
        return ret;
 }
index c2cc83182f9a6b8ae3aa0b2cee1b5b28fd12c7f3..07624a1d7f6a8d1b2acb2a32adb31cc1b46b980c 100755 (executable)
@@ -5,6 +5,7 @@ test_description='push from/to a shallow clone over http'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-httpd.sh
 start_httpd