diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-02-09 08:11:34 -0800 |
---|---|---|
committer | Jesse Vincent <jesse@bestpractical.com> | 2010-02-09 08:29:00 -0800 |
commit | b9ad13acb338e137b9560a8b578e1f7c983706be (patch) | |
tree | 97af2c1b5fb29ce34a1fdd518800ee29c0ad8509 /regcomp.c | |
parent | 3141af47a8bc3e77d5fb9552cf3d33e5b7413d7a (diff) | |
download | perl-b9ad13acb338e137b9560a8b578e1f7c983706be.tar.gz |
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.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -9457,6 +9457,7 @@ Perl_reg_temp_copy (pTHX_ REGEXP *ret_x, REGEXP *rx) memcpy(&(ret->xpv_cur), &(r->xpv_cur), sizeof(regexp) - STRUCT_OFFSET(regexp, xpv_cur)); SvLEN_set(ret_x, 0); + SvSTASH_set(ret_x, NULL); Newx(ret->offs, npar, regexp_paren_pair); Copy(r->offs, ret->offs, npar, regexp_paren_pair); if (r->substrs) { |