Stop char classes from leaking
authorFather Chrysostomos <sprout@cpan.org>
Sat, 3 Nov 2012 13:01:19 +0000 (06:01 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 5 Nov 2012 06:45:30 +0000 (22:45 -0800)
commit2e880be705313389843cfb10a460d634e9d54ce7
tree9c3f7f245c2ffd632fe564d986146b537dfa9e2f
parent8b3001cd63527bb84d5852d1174805737a474abf
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.
regcomp.c
t/op/svleak.t