PATCH for #37138: using XSUB as DB::DB causes perl to crash
Salvador FandiƱo [Mon, 19 Sep 2005 06:56:39 +0000 (23:56 -0700)]
Message-ID: <20050919135639.96726.qmail@web52701.mail.yahoo.com>

(adapted to bleadperl)

p4raw-id: //depot/perl@25511

pp_ctl.c

index 0e31353..12e49ec 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1771,13 +1771,24 @@ PP(pp_dbstate)
        hasargs = 0;
        SPAGAIN;
 
-       PUSHBLOCK(cx, CXt_SUB, SP);
-       PUSHSUB_DB(cx);
-       cx->blk_sub.retop = PL_op->op_next;
-       CvDEPTH(cv)++;
-       SAVECOMPPAD();
-       PAD_SET_CUR_NOSAVE(CvPADLIST(cv), 1);
-       RETURNOP(CvSTART(cv));
+       if (CvXSUB(cv)) {
+           CvDEPTH(cv)++;
+           PUSHMARK(SP);
+           (void)(*CvXSUB(cv))(aTHX_ cv);
+           CvDEPTH(cv)--;
+           FREETMPS;
+           LEAVE;
+           return NORMAL;
+       }
+       else {
+           PUSHBLOCK(cx, CXt_SUB, SP);
+           PUSHSUB_DB(cx);
+           cx->blk_sub.retop = PL_op->op_next;
+           CvDEPTH(cv)++;
+           SAVECOMPPAD();
+           PAD_SET_CUR_NOSAVE(CvPADLIST(cv), 1);
+           RETURNOP(CvSTART(cv));
+       }
     }
     else
        return NORMAL;