summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2017-12-10 07:07:07 -0800
committerFather Chrysostomos <sprout@cpan.org>2017-12-10 11:18:57 -0800
commita01f4640266aacbed7ecc9df01890abb555c69b2 (patch)
tree943ee322c5918a33b3a05c9a308e4e8b59166447 /pp_ctl.c
parente7afb05e35570e271ae017d47b64dd5aad3e2009 (diff)
downloadperl-a01f4640266aacbed7ecc9df01890abb555c69b2.tar.gz
[perl #74764] Forbid ‘goto’ jumping into ‘given’
It does not make sense to jump into a ‘given’ any more than it makes sense to jump into ‘foreach’, which has long been forbidden, since there is no value to turn into a topic. Up till now this construct has always crashed.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index f5ae9e3b96..9ff2abecd3 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2658,7 +2658,8 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstac
o->op_type == OP_SCOPE ||
o->op_type == OP_LEAVELOOP ||
o->op_type == OP_LEAVESUB ||
- o->op_type == OP_LEAVETRY)
+ o->op_type == OP_LEAVETRY ||
+ o->op_type == OP_LEAVEGIVEN)
{
*ops++ = cUNOPo->op_first;
if (ops >= oplimit)
@@ -2718,6 +2719,9 @@ S_check_op_type(pTHX_ OP * const o)
if (o->op_type == OP_ENTERITER)
Perl_croak(aTHX_
"Can't \"goto\" into the middle of a foreach loop");
+ if (o->op_type == OP_ENTERGIVEN)
+ Perl_croak(aTHX_
+ "Can't \"goto\" into a \"given\" block");
}
/* also used for: pp_dump() */