diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-09-10 08:57:15 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-09-10 09:26:13 -0700 |
commit | 04d9744f839dc90f27f08f94cc26f8bb33b3adfa (patch) | |
tree | de0ce881b85017f45a0060e5e5d6aa344ae877cb /commit.h | |
parent | db629c61f0be3665a36750fe2353b9ee958b0376 (diff) |
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 'commit.h')
0 files changed, 0 insertions, 0 deletions