builtin/diff: free symmetric diff members

We populate a `struct symdiff` in case the user has requested a symmetric diff. Part of this is to populate a `skip` bitmap that indicates which commits shall be ignored in the diff. But while this bitmap is dynamically allocated, we never free it. Fix this by introducing and calling a new `symdiff_release()` function that does this for us. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Aug 14, 2024 at 08:52 UTC 77d4b3dd73c44b2c617345a6d9686d2f7f5b8a68
3 files changed +8
builtin/diff.c
+6
@@ -388,6 +388,11 @@ static void symdiff_prepare(struct rev_info *rev, struct symdiff *sym)
388 sym->skip = map;
389 }
390
391 +static void symdiff_release(struct symdiff *sdiff)
392 +{
393 + bitmap_free(sdiff->skip);
394 +}
395 +
396 int cmd_diff(int argc, const char **argv, const char *prefix)
397 {
398 int i;
@@ -619,6 +624,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
624 refresh_index_quietly();
625 release_revisions(&rev);
626 object_array_clear(&ent);
627 + symdiff_release(&sdiff);
628 UNLEAK(blob);
629 return result;
630 }
t/t4068-diff-symmetric-merge-base.sh
+1
@@ -5,6 +5,7 @@ test_description='behavior of diff with symmetric-diff setups and --merge-base'
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 # build these situations:
t/t4108-apply-threeway.sh
+1
@@ -5,6 +5,7 @@ test_description='git apply --3way'
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 print_sanitized_conflicted_diff () {