shallow: fix leaking members of `struct shallow_info`

We do not free several struct members in `clear_shallow_info()`. Fix this to plug the resulting leaks. 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:09 UTC 16c6fb5a94231e76f618eefc7a683fd12091968a
2 files changed +10
shallow.c
+9
@@ -489,6 +489,15 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
489
490 void clear_shallow_info(struct shallow_info *info)
491 {
492 + if (info->used_shallow) {
493 + for (size_t i = 0; i < info->shallow->nr; i++)
494 + free(info->used_shallow[i]);
495 + free(info->used_shallow);
496 + }
497 +
498 + free(info->need_reachability_test);
499 + free(info->reachable);
500 + free(info->shallow_ref);
501 free(info->ours);
502 free(info->theirs);
503 }
t/t5538-push-shallow.sh
+1
@@ -5,6 +5,7 @@ test_description='push from/to a shallow clone'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 +TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 commit() {