This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH for #37138: using XSUB as DB::DB causes perl to crash
authorSalvador Fandiño <sfandino@yahoo.com>
Mon, 19 Sep 2005 06:56:39 +0000 (23:56 -0700)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 20 Sep 2005 09:02:17 +0000 (09:02 +0000)
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;