[perl #20408] SV's SvPVX get freed even when its SvLEN is zero
Adrian M. Enache [Mon, 20 Jan 2003 01:54:07 +0000 (01:54 +0000)]
From: "enache@rdslink.ro (via RT)" <perlbug-followup@perl.org>
Message-Id: <rt-20408-49009.18.2567818321236@bugs6.perl.org>

p4raw-id: //depot/perl@18522

pp_hot.c

index 461c666..1a40441 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2129,7 +2129,8 @@ PP(pp_subst)
            sv_catpvn(dstr, s, strend - s);
 
        (void)SvOOK_off(TARG);
-       Safefree(SvPVX(TARG));
+       if (SvLEN(TARG))
+           Safefree(SvPVX(TARG));
        SvPVX(TARG) = SvPVX(dstr);
        SvCUR_set(TARG, SvCUR(dstr));
        SvLEN_set(TARG, SvLEN(dstr));