]> git.ipfire.org Git - thirdparty/git.git/commitdiff
shallow: fix leaking members of `struct shallow_info`
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Sep 2024 10:09:17 +0000 (12:09 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Sep 2024 15:49:12 +0000 (08:49 -0700)
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>
shallow.c
t/t5538-push-shallow.sh

index 7e0ee96ead99f3ecc23f32344acc1c43ca8e2faa..dcebc263d704ce9cb2eb63047617b8b6e2c702a9 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -489,6 +489,15 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
 
 void clear_shallow_info(struct shallow_info *info)
 {
+       if (info->used_shallow) {
+               for (size_t i = 0; i < info->shallow->nr; i++)
+                       free(info->used_shallow[i]);
+               free(info->used_shallow);
+       }
+
+       free(info->need_reachability_test);
+       free(info->reachable);
+       free(info->shallow_ref);
        free(info->ours);
        free(info->theirs);
 }
index e91fcc173e811664a2ca7fb504f551e79dfb89e5..6adc3a20a45b77aea252d7073025f57060c1797e 100755 (executable)
@@ -5,6 +5,7 @@ test_description='push from/to a shallow clone'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 commit() {