]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/diff: free symmetric diff members
authorPatrick Steinhardt <ps@pks.im>
Wed, 14 Aug 2024 06:52:58 +0000 (08:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Aug 2024 17:08:02 +0000 (10:08 -0700)
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>
builtin/diff.c
t/t4068-diff-symmetric-merge-base.sh
t/t4108-apply-threeway.sh

index 9b6cdabe158b475d4a0b3233deb398ec3a583539..6eac445579b22ff00421b87105822d661616652b 100644 (file)
@@ -388,6 +388,11 @@ static void symdiff_prepare(struct rev_info *rev, struct symdiff *sym)
        sym->skip = map;
 }
 
+static void symdiff_release(struct symdiff *sdiff)
+{
+       bitmap_free(sdiff->skip);
+}
+
 int cmd_diff(int argc, const char **argv, const char *prefix)
 {
        int i;
@@ -619,6 +624,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                refresh_index_quietly();
        release_revisions(&rev);
        object_array_clear(&ent);
+       symdiff_release(&sdiff);
        UNLEAK(blob);
        return result;
 }
index eff63c16b064d124b59a2e4b310e3ce5e190c532..4d6565e728bccd1bb284769cef2a1b05e6f2b622 100755 (executable)
@@ -5,6 +5,7 @@ test_description='behavior of diff with symmetric-diff setups and --merge-base'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # build these situations:
index c558282bc0947548760b0e0cfce68f29f8dc2835..3211e1e65fcf55b7abdd2c254d3ef528d28cd25a 100755 (executable)
@@ -5,6 +5,7 @@ test_description='git apply --3way'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 print_sanitized_conflicted_diff () {