Skip to content

Commit 968b394

Browse files
author
Gurusamy Sarathy
committed
call_method(...,G_EVAL) can longjmp() out if the method probing
failed (from Gisle Aas) p4raw-id: //depot/perl@6127
1 parent c9d5ac9 commit 968b394

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

cop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ L<perlcall>.
423423
#define G_NOARGS 8 /* Don't construct a @_ array. */
424424
#define G_KEEPERR 16 /* Append errors to $@, don't overwrite it */
425425
#define G_NODEBUG 32 /* Disable debugging at toplevel. */
426+
#define G_METHOD 64 /* Calling method. */
426427

427428
/* flag bits for PL_in_eval */
428429
#define EVAL_NULL 0 /* not in an eval */

perl.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,18 +1570,7 @@ Perl_call_method(pTHX_ const char *methname, I32 flags)
15701570
/* name of the subroutine */
15711571
/* See G_* flags in cop.h */
15721572
{
1573-
dSP;
1574-
OP myop;
1575-
if (!PL_op) {
1576-
Zero(&myop, 1, OP);
1577-
PL_op = &myop;
1578-
}
1579-
XPUSHs(sv_2mortal(newSVpv(methname,0)));
1580-
PUTBACK;
1581-
pp_method();
1582-
if (PL_op == &myop)
1583-
PL_op = Nullop;
1584-
return call_sv(*PL_stack_sp--, flags);
1573+
return call_sv(sv_2mortal(newSVpv(methname,0)), flags | G_METHOD);
15851574
}
15861575

15871576
/* May be called with any of a CV, a GV, or an SV containing the name. */
@@ -1601,6 +1590,7 @@ Perl_call_sv(pTHX_ SV *sv, I32 flags)
16011590
{
16021591
dSP;
16031592
LOGOP myop; /* fake syntax tree node */
1593+
UNOP method_op;
16041594
I32 oldmark;
16051595
I32 retval;
16061596
I32 oldscope;
@@ -1638,6 +1628,14 @@ Perl_call_sv(pTHX_ SV *sv, I32 flags)
16381628
&& !(flags & G_NODEBUG))
16391629
PL_op->op_private |= OPpENTERSUB_DB;
16401630

1631+
if (flags & G_METHOD) {
1632+
Zero(&method_op, 1, UNOP);
1633+
method_op.op_next = PL_op;
1634+
method_op.op_ppaddr = PL_ppaddr[OP_METHOD];
1635+
myop.op_ppaddr = PL_ppaddr[OP_ENTERSUB];
1636+
PL_op = &method_op;
1637+
}
1638+
16411639
if (!(flags & G_EVAL)) {
16421640
CATCH_SET(TRUE);
16431641
call_body((OP*)&myop, FALSE);
@@ -1655,7 +1653,7 @@ Perl_call_sv(pTHX_ SV *sv, I32 flags)
16551653
ENTER;
16561654
SAVETMPS;
16571655

1658-
push_return(PL_op->op_next);
1656+
push_return(Nullop);
16591657
PUSHBLOCK(cx, (CXt_EVAL|CXp_TRYBLOCK), PL_stack_sp);
16601658
PUSHEVAL(cx, 0, 0);
16611659
PL_eval_root = PL_op; /* Only needed so that goto works right. */

0 commit comments

Comments
 (0)