This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop char classes from leaking
Since 5.10.0, this script has leaked:
$ perl -e 'warn$$; while(1){eval "/[:]/"}'
What exactly has leaked has changed over time. In bleadperl
it is this:
SV = PV(0x8033c8) at 0x836170
REFCNT = 1
FLAGS = ()
PV = 0x31c0b0 "\2\0\0\0\377\377\377\377\0\0\0\0\f\fS\21\1\0\0\0:\0\0\0;\0\0\0"\0
CUR = 28
LEN = 32
This only happens when the character class has only one character in
it, the same character repeated ([aa]), or a multicharacter fold.
A character class is usually compiled as an ANYOF node, but [A] is
optimised down to just A (and EXACT) and /[\xdf]/i is rewritten into a
more complex expression.
When the ANYOF node is abandoned, we need to free any temporary SVs
created in the mean time. A few of them were leaking.