Fix MULTICALL in List-Util
Alex Vandiver [Sat, 7 Mar 2009 07:44:40 +0000 (02:44 -0500)]
Add a new stack frame; the MULTICALL code in pp_return assumes there
is a clean stack, and blindly changes the top-most stack value.  This
change brings cop.h more in line with the "poor-man's MULTICALL"
provided in ext/List-Util/multicall.h, which also always pushes a new
stack.

cop.h

diff --git a/cop.h b/cop.h
index 39a6b01..0c85a4b 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -883,6 +883,7 @@ See L<perlcall/Lightweight Callbacks>.
        multicall_oldcatch = CATCH_GET;                                 \
        SAVETMPS; SAVEVPTR(PL_op);                                      \
        CATCH_SET(TRUE);                                                \
+       PUSHSTACKi(PERLSI_SORT);                                        \
        PUSHBLOCK(cx, CXt_SUB|CXp_MULTICALL, PL_stack_sp);              \
        PUSHSUB(cx);                                                    \
        if (++CvDEPTH(cv) >= 2) {                                       \
@@ -906,8 +907,10 @@ See L<perlcall/Lightweight Callbacks>.
        LEAVESUB(multicall_cv);                                         \
        CvDEPTH(multicall_cv)--;                                        \
        POPBLOCK(cx,PL_curpm);                                          \
+       POPSTACK;                                                       \
        CATCH_SET(multicall_oldcatch);                                  \
        LEAVE;                                                          \
+       SPAGAIN;                                                        \
     } STMT_END
 
 /*