This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Encoding neutral unpack
[perl5.git] / util.c
diff --git a/util.c b/util.c
index 3598e7b..fc99463 100644 (file)
--- a/util.c
+++ b/util.c
@@ -758,10 +758,18 @@ char *
 Perl_savepv(pTHX_ const char *pv)
 {
     register char *newaddr;
+#ifdef PERL_MALLOC_WRAP
+    STRLEN pvlen;
+#endif
     if (!pv)
        return Nullch;
 
+#ifdef PERL_MALLOC_WRAP
+    pvlen = strlen(pv)+1;
+    New(902,newaddr,pvlen,char);
+#else
     New(902,newaddr,strlen(pv)+1,char);
+#endif
     return strcpy(newaddr,pv);
 }
 
@@ -822,7 +830,7 @@ Perl_savesharedpv(pTHX_ const char *pv)
 /*
 =for apidoc savesvpv
 
-A version of C<savepv()>/C<savepvn() which gets the string to duplicate from
+A version of C<savepv()>/C<savepvn()> which gets the string to duplicate from
 the passed in SV using C<SvPV()>
 
 =cut
@@ -835,7 +843,8 @@ Perl_savesvpv(pTHX_ SV *sv)
     const char *pv = SvPV(sv, len);
     register char *newaddr;
 
-    New(903,newaddr,++len,char);
+    ++len;
+    New(903,newaddr,len,char);
     return CopyD(pv,newaddr,len,char);
 }