Fix SvGROW on an SV with SvLEN == 0 - copy in any existing data.
Nick Ing-Simmons [Sun, 3 Feb 2002 14:54:18 +0000 (14:54 +0000)]
(Mis-feature discovered by Encode.)

p4raw-id: //depot/perlio@14526

sv.c

diff --git a/sv.c b/sv.c
index 8f5b0a6..217df87 100644 (file)
--- 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);