diff options
author | David Mitchell <davem@iabyn.com> | 2013-03-18 16:41:42 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2013-03-18 16:41:42 +0000 |
commit | da1f5b59634bdfea59787843016be4809df50836 (patch) | |
tree | 32dfebcbf85eed4d0d7dce4074ad8ebd7ed84f17 /regcomp.c | |
parent | cdac396140ede59138b67af076981d0438e36b8b (diff) | |
download | perl-da1f5b59634bdfea59787843016be4809df50836.tar.gz |
fix a segfault in run-time qr//s with (?{})
While assembling the regex, it was was examining CONSTs in the optree
using the wrong pad. When consts are moved into the pad on threaded
builds, segvs might be the result.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -5315,8 +5315,15 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count, int ncode = 0; for (o = cLISTOPx(expr)->op_first; o; o = o->op_sibling) { - if (o->op_type == OP_CONST && SvUTF8(cSVOPo_sv)) - code_is_utf8 = 1; + if (o->op_type == OP_CONST) { + /* skip if we have SVs as well as OPs. In this case, + * a) we decide utf8 based on SVs not OPs; + * b) the current pad may not match that which the ops + * were compiled in, so, so on threaded builds, + * cSVOPo_sv would look in the wrong pad */ + if (!pat_count && SvUTF8(cSVOPo_sv)) + code_is_utf8 = 1; + } else if (o->op_type == OP_NULL && (o->op_flags & OPf_SPECIAL)) /* count of DO blocks */ ncode++; |