]> perl5.git.perl.org Git - perl5.git/commit This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
safer cleanup when failing to compile regexps
authorTony Cook <[email protected]>
Wed, 29 Nov 2023 04:51:17 +0000 (15:51 +1100)
committermauke <[email protected]>
Sun, 4 Aug 2024 12:02:07 +0000 (14:02 +0200)
commit388bf71121e682302397a8b7d9f56fef5ba2559e
treec9ca701365021ae0f06849b3d876337ff9d26a5c
parentc9e5693c3bd5a506e29ece21256a1c07a6668a8e
safer cleanup when failing to compile regexps

Prior to this commit when producing a warning the regexp compiler
would check if the warning category was marked as FATAL, and if it was
it would add clean up to the save stack to release buffers used during
compilation and to release the working REGEXP SV.

This causes two type of problems:

- if an error was already queued, Perl_ck_warner() returns even if
  the warning is fatal, this meant that the normal clean up code
  Perl_re_op_compile() would also run, resulting in a double free
  of the buffers.

- without fatal warnings, if a $SIG{__WARN__} handler died, the
  buffers and the working REGEXP SV would leak.

Avoid this by using SAVEDESTRUCTOR_X() to release the memory and
optionally the SV at the end of scope.

Fixes #21661
regcomp.c
regcomp_internal.h