builtin/submodule--helper: fix leaking refs on push-check

In the push-check subcommand of the submodule helper we acquire a list of local refs, but never free that list. Fix this memory leak. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Sep 5, 2024 at 12:08 UTC 1e8cb17ac5c0e7871e15dd40bacd617f25a54763
2 files changed +3
builtin/submodule--helper.c
+2
@@ -2958,7 +2958,9 @@ static int push_check(int argc, const char **argv, const char *prefix UNUSED)
2958 rs->src);
2959 }
2960 }
2961 +
2962 refspec_clear(&refspec);
2963 + free_refs(local_refs);
2964 }
2965 free(head);
2966
t/t5531-deep-submodule-push.sh
+1
@@ -8,6 +8,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
9 export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
10
11 +TEST_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
13
14 test_expect_success setup '