builtin/send-pack: fix leaking refspecs

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>

Patrick Steinhardt committed Aug 22, 2024 at 11:17 UTC a09efb74e3d3b316519a398618fb6515df4337a7
6 files changed +9
builtin/send-pack.c
+1
@@ -338,5 +338,6 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
338
339 free_refs(remote_refs);
340 free_refs(local_refs);
341 + refspec_clear(&rs);
342 return ret;
343 }
t/t5400-send-pack.sh
+1
@@ -9,6 +9,7 @@ test_description='See why rewinding head breaks send-pack
9 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
10 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11
12 +TEST_PASSES_SANITIZE_LEAK=true
13 . ./test-lib.sh
14
15 cnt=64
t/t5401-update-hooks.sh
+2
@@ -4,6 +4,8 @@
4 #
5
6 test_description='Test the update hook infrastructure.'
7 +
8 +TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 test_expect_success setup '
t/t5408-send-pack-stdin.sh
+2
@@ -1,6 +1,8 @@
1 #!/bin/sh
2
3 test_description='send-pack --stdin tests'
4 +
5 +TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 create_ref () {
t/t5548-push-porcelain.sh
+1
@@ -4,6 +4,7 @@
4 #
5 test_description='Test git push porcelain output'
6
7 +TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
9
10 # Create commits in <repo> and assign each commit's oid to shell variables
t/t5812-proto-disable-http.sh
+2
@@ -1,6 +1,8 @@
1 #!/bin/sh
2
3 test_description='test disabling of git-over-http in clone/fetch'
4 +
5 +TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY/lib-proto-disable.sh"
8 . "$TEST_DIRECTORY/lib-httpd.sh"