This commit that turned up this bug turns out merely exposes an
underlying problem that could be generated via other means.
regcomp.c was looking at the SvUTF8 flag on the input pattern before
doing an SvPV on it. Generally the flag is considered not reliable
unless checked immediately after a SvPV.
I haven't been able to come up with a simple test case that reproduces
the bug. I suspect that XS code is required to trigger it.
[ this is a re-application by davem of commit
11951bcbfcaf4c260b0da0421e72fc80b4654f17 ]
pat = *patternp;
}
- RExC_utf8 = RExC_orig_utf8 = SvUTF8(pat);
+ exp = SvPV(pat, plen);
+
+ if (plen == 0) { /* ignore the utf8ness if the pattern is 0 length */
+ RExC_utf8 = RExC_orig_utf8 = 0;
+ }
+ else {
+ RExC_utf8 = RExC_orig_utf8 = SvUTF8(pat);
+ }
RExC_uni_semantics = 0;
RExC_contains_locale = 0;
}
if (jump_ret == 0) { /* First time through */
- exp = SvPV(pat, plen);
xend = exp + plen;
- /* ignore the utf8ness if the pattern is 0 length */
- if (plen == 0) {
- RExC_utf8 = RExC_orig_utf8 = 0;
- }
DEBUG_COMPILE_r({
SV *dsv= sv_newmortal();