There is a todo comment in `release_revisions()` that mentions that we
need to free the diff options, which was added via 54c8a7c379 (revisions
API: add a TODO for diff_free(&revs->diffopt), 2022-04-14). Releasing
the diff options wasn't quite feasible at that time because some call
sites rely on its contents to remain even after the revisions have been
released.
In fact, there really only are a couple of callsites that misbehave
here:
- `cmd_shortlog()` releases the revisions, but continues to access its
file pointer.
- `do_diff_cache()` creates a shallow copy of `struct diff_options`,
but does not set the `no_free` member. Consequently, we end up
releasing resources of the caller-provided diff options.
- `diff_free()` and friends do not play nice when being called
multiple times as they don't unset data structures that they have
just released.
Fix all of those cases and enable the call to `diff_free()`, which plugs
a bunch of memory leaks.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committedJun 11, 2024 at 11:20 UTCa90a08961190dda2f664e102822fb6a7152e65d5
index 73a2465aa0..3553bbbfe7 100755--- a/t/t6001-rev-list-graft.sh+++ b/t/t6001-rev-list-graft.sh@@ -5,6 +5,7 @@ test_description='Revision traversal vs grafts and path limiter' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME+TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup '
t/t6013-rev-list-reverse-parents.sh
+1
index 39793cbbd6..4128269c1d 100755--- a/t/t6013-rev-list-reverse-parents.sh+++ b/t/t6013-rev-list-reverse-parents.sh@@ -5,6 +5,7 @@ test_description='--reverse combines with --parents' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME+TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh
t/t6017-rev-list-stdin.sh
+1
index 4821b90e74..a0a40fe55c 100755--- a/t/t6017-rev-list-stdin.sh+++ b/t/t6017-rev-list-stdin.sh@@ -8,6 +8,7 @@ test_description='log family learns --stdin' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME+TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh check () {
t/t9500-gitweb-standalone-no-errors.sh
+1
index 7679780fb8..ccfa415384 100755--- a/t/t9500-gitweb-standalone-no-errors.sh+++ b/t/t9500-gitweb-standalone-no-errors.sh@@ -13,6 +13,7 @@ or warnings to log.' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME+TEST_PASSES_SANITIZE_LEAK=true . ./lib-gitweb.sh # ----------------------------------------------------------------------
t/t9502-gitweb-standalone-parse-output.sh
+1
index 81d5625557..b41ea19331 100755--- a/t/t9502-gitweb-standalone-parse-output.sh+++ b/t/t9502-gitweb-standalone-parse-output.sh@@ -13,6 +13,7 @@ in the HTTP header or the actual script output.' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME+TEST_PASSES_SANITIZE_LEAK=true . ./lib-gitweb.sh # ----------------------------------------------------------------------