Avoid taking a reference to SvIVX and putting that address on the
Nicholas Clark [Mon, 11 Apr 2005 14:53:38 +0000 (14:53 +0000)]
save stack

p4raw-id: //depot/perl@24228

perl.c
pp_ctl.c
pp_hot.c

diff --git a/perl.c b/perl.c
index 6d948e7..6967c8c 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -3906,7 +3906,6 @@ Perl_init_debugger(pTHX)
     PL_DBgv = gv_fetchpv("DB::DB", GV_ADDMULTI, SVt_PVGV);
     PL_DBline = gv_fetchpv("DB::dbline", GV_ADDMULTI, SVt_PVAV);
     PL_DBsub = gv_HVadd(gv_fetchpv("DB::sub", GV_ADDMULTI, SVt_PVHV));
-    sv_upgrade(GvSV(PL_DBsub), SVt_IV);        /* IVX accessed if PERLDB_SUB_NN */
     PL_DBsingle = GvSV((gv_fetchpv("DB::single", GV_ADDMULTI, SVt_PV)));
     sv_setiv(PL_DBsingle, 0);
     PL_DBtrace = GvSV((gv_fetchpv("DB::trace", GV_ADDMULTI, SVt_PV)));
index 71634fb..933fb3f 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2426,13 +2426,14 @@ PP(pp_goto)
                    SV *sv = GvSV(PL_DBsub);
                    CV *gotocv;
 
+                   save_item(sv);
                    if (PERLDB_SUB_NN) {
-                       (void)SvUPGRADE(sv, SVt_PVIV);
+                       int type = SvTYPE(sv);
+                       if (type < SVt_PVIV && type != SVt_IV)
+                           sv_upgrade(sv, SVt_PVIV);
                        (void)SvIOK_on(sv);
-                       SAVEIV(SvIVX(sv));
                        SvIV_set(sv, PTR2IV(cv)); /* Do it the quickest way */
                    } else {
-                       save_item(sv);
                        gv_efullname3(sv, CvGV(cv), Nullch);
                    }
                    if (  PERLDB_GOTO
index 85b42aa..b486586 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2560,10 +2560,10 @@ S_get_db_sub(pTHX_ SV **svp, CV *cv)
 {
     SV *dbsv = GvSV(PL_DBsub);
 
+    save_item(dbsv);
     if (!PERLDB_SUB_NN) {
        GV *gv = CvGV(cv);
 
-       save_item(dbsv);
        if ( (CvFLAGS(cv) & (CVf_ANON | CVf_CLONED))
             || strEQ(GvNAME(gv), "END")
             || ((GvCV(gv) != cv) && /* Could be imported, and old sub redefined. */
@@ -2580,9 +2580,10 @@ S_get_db_sub(pTHX_ SV **svp, CV *cv)
        }
     }
     else {
-       (void)SvUPGRADE(dbsv, SVt_PVIV);
+       int type = SvTYPE(dbsv);
+       if (type < SVt_PVIV && type != SVt_IV)
+           sv_upgrade(dbsv, SVt_PVIV);
        (void)SvIOK_on(dbsv);
-       SAVEIV(SvIVX(dbsv));
        SvIV_set(dbsv, PTR2IV(cv));     /* Do it the quickest way  */
     }