Re: [perl #18257] Attempt to free unreferenced scalar (in 5 lines)
Hugo van der Sanden [Thu, 2 Jan 2003 17:16:04 +0000 (17:16 +0000)]
Message-Id: <200301021716.h02HG5809404@crypt.compulink.co.uk>

p4raw-id: //depot/perl@18407

sv.c

diff --git a/sv.c b/sv.c
index 478097f..e522a47 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3762,7 +3762,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
                switch (SvTYPE(sref)) {
                case SVt_PVAV:
                    if (intro)
-                       SAVESPTR(GvAV(dstr));
+                       SAVEGENERICSV(GvAV(dstr));
                    else
                        dref = (SV*)GvAV(dstr);
                    GvAV(dstr) = (AV*)sref;
@@ -3774,7 +3774,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
                    break;
                case SVt_PVHV:
                    if (intro)
-                       SAVESPTR(GvHV(dstr));
+                       SAVEGENERICSV(GvHV(dstr));
                    else
                        dref = (SV*)GvHV(dstr);
                    GvHV(dstr) = (HV*)sref;
@@ -3792,7 +3792,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
                            GvCVGEN(dstr) = 0; /* Switch off cacheness. */
                            PL_sub_generation++;
                        }
-                       SAVESPTR(GvCV(dstr));
+                       SAVEGENERICSV(GvCV(dstr));
                    }
                    else
                        dref = (SV*)GvCV(dstr);
@@ -3842,21 +3842,21 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
                    break;
                case SVt_PVIO:
                    if (intro)
-                       SAVESPTR(GvIOp(dstr));
+                       SAVEGENERICSV(GvIOp(dstr));
                    else
                        dref = (SV*)GvIOp(dstr);
                    GvIOp(dstr) = (IO*)sref;
                    break;
                case SVt_PVFM:
                    if (intro)
-                       SAVESPTR(GvFORM(dstr));
+                       SAVEGENERICSV(GvFORM(dstr));
                    else
                        dref = (SV*)GvFORM(dstr);
                    GvFORM(dstr) = (CV*)sref;
                    break;
                default:
                    if (intro)
-                       SAVESPTR(GvSV(dstr));
+                       SAVEGENERICSV(GvSV(dstr));
                    else
                        dref = (SV*)GvSV(dstr);
                    GvSV(dstr) = sref;
@@ -3869,8 +3869,6 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
                }
                if (dref)
                    SvREFCNT_dec(dref);
-               if (intro)
-                   SAVEFREESV(sref);
                if (SvTAINTED(sstr))
                    SvTAINT(dstr);
                return;