]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/send-pack: fix leaking refspecs
authorPatrick Steinhardt <ps@pks.im>
Thu, 22 Aug 2024 09:17:46 +0000 (11:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2024 16:18:05 +0000 (09:18 -0700)
We never free data associated with the assembled refspec in
git-send-pack(1), causing a memory leak. Fix this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/send-pack.c
t/t5400-send-pack.sh
t/t5401-update-hooks.sh
t/t5408-send-pack-stdin.sh
t/t5548-push-porcelain.sh
t/t5812-proto-disable-http.sh

index 17cae6bbbdf298918ba75e7e78c73b1e5d154778..ef0df8082493d7d01435282597a25820097e2277 100644 (file)
@@ -338,5 +338,6 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 
        free_refs(remote_refs);
        free_refs(local_refs);
+       refspec_clear(&rs);
        return ret;
 }
index 3f81f16e1335ce6e7f3c8e8d164e140e26049e6f..248c74d8ef2e1be8f882d7692dea81c417d829d6 100755 (executable)
@@ -9,6 +9,7 @@ test_description='See why rewinding head breaks send-pack
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 cnt=64
index d8cadeec73310d36ad11a1427ec44cc9fc2d3a66..3c1ea6086e7d2817bc14d59c28153fe215a08c18 100755 (executable)
@@ -4,6 +4,8 @@
 #
 
 test_description='Test the update hook infrastructure.'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success setup '
index e8737df6f95cde09b97bddba1425253039e58dbc..c3695a4d4e3bbf43b815206f9334327868b7d149 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='send-pack --stdin tests'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 create_ref () {
index 6282728eaf3e7871d99fea48357298f6b14c9fd2..ecb3877aa4bf1b25942598ef5f1628d91c9bfbd5 100755 (executable)
@@ -4,6 +4,7 @@
 #
 test_description='Test git push porcelain output'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # Create commits in <repo> and assign each commit's oid to shell variables
index 769c717e88b83de123a33e9c9bc4b52d192a780a..f69959c64ca708f1cb8a141eb60c37567b736629 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='test disabling of git-over-http in clone/fetch'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY/lib-proto-disable.sh"
 . "$TEST_DIRECTORY/lib-httpd.sh"