pp_undef was not always freeing memory
authorIlya Zakharevich <ilya@math.ohio-state.edu>
Thu, 27 Feb 1997 06:53:51 +0000 (01:53 -0500)
committerChip Salzenberg <chip@atlantic.net>
Tue, 25 Feb 1997 01:12:02 +0000 (13:12 +1200)
As I found, pp_undef in
$a = 'aaa';
$a = 0;
undef $a;
was not reclaiming the storage, as it does in
        $a = 'aaa';
        undef $a;

The patch is below fixes this shortcoming (tests ok, perl rebuilds
itself OK),

Enjoy,

p5p-msgid: <199702270707.CAA13978@monk.mps.ohio-state.edu>
private-msgid: <199702270653.BAA13949@monk.mps.ohio-state.edu>

pp.c

diff --git a/pp.c b/pp.c
index 62a01ec..0e924a3 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -555,7 +555,7 @@ PP(pp_undef)
            sv_setsv(sv, &sv_undef);
        break;
     default:
-       if (SvPOK(sv) && SvLEN(sv)) {
+       if (SvTYPE(sv) >= SVt_PV && SvPVX(sv) && SvLEN(sv)) {
            (void)SvOOK_off(sv);
            Safefree(SvPVX(sv));
            SvPV_set(sv, Nullch);