Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 37040543d024b3ecb0aecd78849bd5af61408d02
      
https://github.com/Perl/perl5/commit/37040543d024b3ecb0aecd78849bd5af61408d02
  Author: Yves Orton <demer...@gmail.com>
  Date:   2023-01-15 (Sun, 15 Jan 2023)

  Changed paths:
    M MANIFEST
    M ext/XS-APItest/APItest.xs
    A ext/XS-APItest/t/savestack.t
    M regexec.c

  Log Message:
  -----------
  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.


Reply via email to