summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-02-09 08:11:34 -0800
committerJesse Vincent <jesse@bestpractical.com>2010-02-09 08:29:00 -0800
commitb9ad13acb338e137b9560a8b578e1f7c983706be (patch)
tree97af2c1b5fb29ce34a1fdd518800ee29c0ad8509 /regcomp.c
parent3141af47a8bc3e77d5fb9552cf3d33e5b7413d7a (diff)
downloadperl-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.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index 10f97b93ea..ecea32d4e3 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -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) {