Fix MULTICALL in List-Util
authorAlex Vandiver <alexmv@mit.edu>
Sat, 7 Mar 2009 07:44:40 +0000 (02:44 -0500)
committerDavid Mitchell <davem@iabyn.com>
Wed, 15 Apr 2009 18:51:08 +0000 (19:51 +0100)
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.

(cherry picked from commit 1bbbfc5065f1f4b15e64694ca559c8dbefbb69d2)

cop.h

diff --git a/cop.h b/cop.h
index e5f30a4..f14fbf5 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -864,6 +864,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) {                                       \
@@ -887,8 +888,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
 
 /*