Skip to content

Commit 77d4b3d

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 36f971f commit 77d4b3d

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

builtin/diff.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ static void symdiff_prepare(struct rev_info *rev, struct symdiff *sym)
388388
sym->skip = map;
389389
}
390390

391+
static void symdiff_release(struct symdiff *sdiff)
392+
{
393+
bitmap_free(sdiff->skip);
394+
}
395+
391396
int cmd_diff(int argc, const char **argv, const char *prefix)
392397
{
393398
int i;
@@ -619,6 +624,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
619624
refresh_index_quietly();
620625
release_revisions(&rev);
621626
object_array_clear(&ent);
627+
symdiff_release(&sdiff);
622628
UNLEAK(blob);
623629
return result;
624630
}

t/t4068-diff-symmetric-merge-base.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='behavior of diff with symmetric-diff setups and --merge-base'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910

1011
# build these situations:

t/t4108-apply-threeway.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='git apply --3way'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910

1011
print_sanitized_conflicted_diff () {

0 commit comments

Comments
 (0)