aboutsummaryrefslogtreecommitdiffstats
path: root/t/t6302-for-each-ref-filter.sh
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-09-10 08:57:15 +0200
committerJunio C Hamano <gitster@pobox.com>2024-09-10 09:26:13 -0700
commit04d9744f839dc90f27f08f94cc26f8bb33b3adfa (patch)
treede0ce881b85017f45a0060e5e5d6aa344ae877cb /t/t6302-for-each-ref-filter.sh
parentref-filter: add ref_format_clear() function (diff)
downloadgit-04d9744f839dc90f27f08f94cc26f8bb33b3adfa.tar.gz
git-04d9744f839dc90f27f08f94cc26f8bb33b3adfa.zip
ref-filter: fix leak with unterminated %(if) atoms
When parsing `%(if)` atoms we expect a few other atoms to exist to complete it, like `%(then)` and `%(end)`. Whether or not we have seen these other atoms is tracked in an allocated `if_then_else` structure, which gets free'd by the `if_then_else_handler()` once we have parsed the complete conditional expression. This results in a memory leak when the `%(if)` atom is not terminated correctly and thus incomplete. We never end up executing its handler and thus don't end up freeing the structure. Plug this memory leak by introducing a new `at_end_data_free` callback function. If set, we'll execute it in `pop_stack_element()` and pass it the `at_end_data` variable with the intent to free its state. Wire it up for the `%(if)` atom accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6302-for-each-ref-filter.sh')
-rwxr-xr-xt/t6302-for-each-ref-filter.sh1
1 files changed, 1 insertions, 0 deletions
diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh
index 163c378cfd..7f44d3c3f2 100755
--- a/t/t6302-for-each-ref-filter.sh
+++ b/t/t6302-for-each-ref-filter.sh
@@ -2,6 +2,7 @@
test_description='test for-each-refs usage of ref-filter APIs'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-gpg.sh