Bump up the version and admonish against aspiring (ab)use.
[p5sagit/p5-mst-13.2.git] / pp_ctl.c
index 5143391..0b00685 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1949,6 +1949,7 @@ PP(pp_return)
     }
     PL_stack_sp = newsp;
 
+    LEAVE;
     /* Stack values are safe: */
     if (popsub2) {
        POPSUB(cx,sv);  /* release CV and @_ ... */
@@ -1957,7 +1958,6 @@ PP(pp_return)
        sv = Nullsv;
     PL_curpm = newpm;  /* ... and pop $1 et al */
 
-    LEAVE;
     LEAVESUB(sv);
     if (clear_errsv)
        sv_setpv(ERRSV,"");
@@ -2033,6 +2033,7 @@ PP(pp_last)
     SP = newsp;
     PUTBACK;
 
+    LEAVE;
     /* Stack values are safe: */
     switch (pop2) {
     case CXt_LOOP:
@@ -2045,7 +2046,6 @@ PP(pp_last)
     }
     PL_curpm = newpm;  /* ... and pop $1 et al */
 
-    LEAVE;
     LEAVESUB(sv);
     return nextop;
 }
@@ -2203,6 +2203,7 @@ PP(pp_goto)
            }
 
            /* First do some returnish stuff. */
+           SvREFCNT_inc(cv); /* avoid premature free during unwind */
            FREETMPS;
            cxix = dopoptosub(cxstack_ix);
            if (cxix < 0)
@@ -2250,6 +2251,7 @@ PP(pp_goto)
 
            /* Now do some callish stuff. */
            SAVETMPS;
+           SAVEFREESV(cv); /* later, undo the 'avoid premature free' hack */
            if (CvXSUB(cv)) {
 #ifdef PERL_XSUB_OLDSTYLE
                if (CvOLDSTYLE(cv)) {
@@ -2882,7 +2884,13 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
        *startop = PL_eval_root;
     } else
        SAVEFREEOP(PL_eval_root);
-    if (gimme & G_VOID)
+    if (gimme & G_VOID && ! PL_in_eval & EVAL_INREQUIRE)
+       /*
+        * EVAL_INREQUIRE (the code is being required) is special-cased :
+        * in this case we want scalar context to be forced, instead
+        * of void context, so a proper return value is returned from
+        * C<require> via this leaveeval op.
+        */
        scalarvoid(PL_eval_root);
     else if (gimme & G_ARRAY)
        list(PL_eval_root);