This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix for non-regexps being upgraded to SVt_REGEXP
authorNicholas Clark <nick@ccl4.org>
Tue, 9 Feb 2010 16:11:34 +0000 (08:11 -0800)
committerJesse Vincent <jesse@bestpractical.com>
Tue, 9 Feb 2010 16:29:00 +0000 (08:29 -0800)
commitb9ad13acb338e137b9560a8b578e1f7c983706be
tree97af2c1b5fb29ce34a1fdd518800ee29c0ad8509
parent3141af47a8bc3e77d5fb9552cf3d33e5b7413d7a
Fix for non-regexps being upgraded to SVt_REGEXP

$ ./perl -lwe '$a = ${qr//}; $a = 2; print re::is_regexp(\$a)'
1

It is possible for arbitrary SVs (eg PAD entries) to be upgraded to
SVt_REGEXP.  (This is new with first class regexps)

Whilst the example above does not SEGV, it will be possible to write
code that will cause SEGVs (or worse) at the point when the scalar is freed,
because the code in sv_clear() assumes that all scalars of type
SVt_REGEXP *are* regexps, and passes them to pregfree2(), which assumes that
pointers within are valid.
ext/Devel-Peek/t/Peek.t
regcomp.c
sv.c
t/op/qr.t