From c8f85248c653c2ed4452f5de552ef3f50c4a1120 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sun, 22 Apr 2012 20:19:15 -0700 Subject: [PATCH] [perl #111794] Make goto "" like goto ${\""} MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The logic was written in such a way that goto "" just happened to slip past all the checks and cause pp_goto to return NULL for the next op, which means the end of the program. goto ${\""} dies with ‘goto must have label’, so goto "" should as well. This also adds other tests for that error, which was apparently untested till now. --- pp_ctl.c | 1 + t/op/goto.t | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pp_ctl.c b/pp_ctl.c index 8f4c103..53f22f3 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3056,6 +3056,7 @@ PP(pp_goto) label = cPVOP->op_pv; label_flags = (cPVOP->op_private & OPpPV_IS_UTF8) ? SVf_UTF8 : 0; label_len = strlen(label); + if (!(do_dump || *label)) DIE(aTHX_ must_have_label); } PERL_ASYNC_CHECK(); diff --git a/t/op/goto.t b/t/op/goto.t index cb9c6b6..f042f45 100644 --- a/t/op/goto.t +++ b/t/op/goto.t @@ -10,7 +10,7 @@ BEGIN { use warnings; use strict; -plan tests => 80; +plan tests => 83; our $TODO; my $deprecated = 0; @@ -636,3 +636,10 @@ ok( same_prefix_labels(), "perl 112316: goto and labels with the same prefix doesn't get mixed up" ); + +eval { my $x = ""; goto $x }; +like $@, qr/^goto must have label at /, 'goto $x where $x is empty string'; +eval { goto "" }; +like $@, qr/^goto must have label at /, 'goto ""'; +eval { goto }; +like $@, qr/^goto must have label at /, 'argless goto'; -- 2.7.4