This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Use no_mg for 2nd fetch of pattern
authorKarl Williamson <public@khwilliamson.com>
Sun, 30 Oct 2011 16:47:21 +0000 (16:47 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 13 Jun 2012 12:25:51 +0000 (13:25 +0100)
The pattern could be tied, for example, and so only want to access it
once.  I couldn't come up with a test case that actually exercised this,
but I can think of future changes to regcomp that would.

[ this is a re-application by davem of commit
3e0b93e82af0f1a033bcdb918b413113f1d61cf0 ]

regcomp.c

index 14261a7..6e60737 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -5209,7 +5209,9 @@ Perl_re_op_compile(pTHX_ SV * const * const patternp, int pat_count,
            xend = exp + plen;
        }
        else {
-           exp = (char*)Perl_bytes_to_utf8(aTHX_ (U8*)SvPV(pat, plen), &len);
+           exp = (char*)Perl_bytes_to_utf8(aTHX_
+                                           (U8*)SvPV_nomg(pat, plen),
+                                           &len);
            xend = exp + len;
            SAVEFREEPV(exp);
        }