Fix a bug in the cloning of regexps
Hugo van der Sanden [Thu, 11 Mar 2004 16:21:50 +0000 (16:21 +0000)]
Subject: Re: [perl #27530] Regex qr// interpolation fails when chr(0) is used in a thread
Message-Id: <200403111621.i2BGLoi20225@zen.crypt.org>
(plus another similar fix)

p4raw-id: //depot/perl@22490

sv.c

diff --git a/sv.c b/sv.c
index 70e157d..2d46839 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -9715,7 +9715,7 @@ Perl_re_dup(pTHX_ REGEXP *r, CLONE_PARAMS *param)
     New(0, ret->offsets, 2*len+1, U32);
     Copy(r->offsets, ret->offsets, 2*len+1, U32);
 
-    ret->precomp        = SAVEPV(r->precomp);
+    ret->precomp        = SAVEPVN(r->precomp, r->prelen);
     ret->refcnt         = r->refcnt;
     ret->minlen         = r->minlen;
     ret->prelen         = r->prelen;
@@ -9727,7 +9727,7 @@ Perl_re_dup(pTHX_ REGEXP *r, CLONE_PARAMS *param)
     ret->sublen         = r->sublen;
 
     if (RX_MATCH_COPIED(ret))
-       ret->subbeg  = SAVEPV(r->subbeg);
+       ret->subbeg  = SAVEPVN(r->subbeg, r->sublen);
     else
        ret->subbeg = Nullch;
 #ifdef PERL_COPY_ON_WRITE