From 37040543d024b3ecb0aecd78849bd5af61408d02 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Sat, 14 Jan 2023 11:46:03 +0100 Subject: regexec.c - fix memory leak in EVAL. EVAL was calling regcppush twice per invocation, once before executing the callback, and once after. But not regcppop'ing twice. So each time we would accumulate an extra "frame" of data. This is/was hidden somewhat by the way we eventually "blow" the stack, so the extra data was just thrown away at the end. This removes the second set of pushes so that the save stack stays a stable size as it unwinds from each failed eval. We also weren't cleaning up after a (?{...}) when we failed to match to its right. This unwinds the stack and restores the parens properly. This adds tests to check how the save stack grows during patterns using (?{ ... }) and (??{ ... }) and ensure that when we backtrack and re-execute the EVAL again it cleans up the stack as it goes. --- MANIFEST | 1 + 1 file changed, 1 insertion(+) (limited to 'MANIFEST') diff --git a/MANIFEST b/MANIFEST index 40174a28b4..a153ce7a06 100644 --- a/MANIFEST +++ b/MANIFEST @@ -4677,6 +4677,7 @@ ext/XS-APItest/t/refs.t Test typemap ref handling ext/XS-APItest/t/rmagical.t XS::APItest extension ext/XS-APItest/t/rv2cv_op_cv.t test rv2cv_op_cv() API ext/XS-APItest/t/savehints.t test SAVEHINTS() API +ext/XS-APItest/t/savestack.t test savestack behavior, currently only in the regex engine ext/XS-APItest/t/scopelessblock.t test recursive descent statement-sequence parsing ext/XS-APItest/t/sort.t Test sort(xs_cmp ...) ext/XS-APItest/t/stmtasexpr.t test recursive descent statement parsing -- cgit v1.2.1