From: Nick Ing-Simmons <nik@tiuk.ti.com>
Date: Sun, 3 Feb 2002 14:54:18 +0000 (+0000)
Subject: Fix SvGROW on an SV with SvLEN == 0 - copy in any existing data.
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4056517955bef99f1d248dcaf966c0e256b0ea31;p=p5sagit%2Fp5-mst-13.2.git

Fix SvGROW on an SV with SvLEN == 0 - copy in any existing data.
(Mis-feature discovered by Encode.)

p4raw-id: //depot/perlio@14526
---

diff --git a/sv.c b/sv.c
index 8f5b0a6..217df87 100644
--- a/sv.c
+++ b/sv.c
@@ -1584,6 +1584,9 @@ Perl_sv_grow(pTHX_ register SV *sv, register STRLEN newlen)
 		SvREADONLY_off(sv);
 	    }
 	    New(703, s, newlen, char);
+	    if (SvPVX(sv) && SvCUR(sv)) {
+	        Move(SvPVX(sv), s, SvCUR(sv), char);
+	    }
 	}
 	SvPV_set(sv, s);
         SvLEN_set(sv, newlen);