summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-12 18:03:45 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-12 18:03:45 +0100
commitf84ff042dab5dfcde5d88d3ad4b28d1416321e65 (patch)
tree1b13d57c8c7f3ba998c2ef6b6407b7245f5d7740 /universal.c
parent8abccac8ff0df19277ea7cd5207ec52ac011a3b9 (diff)
downloadperl-f84ff042dab5dfcde5d88d3ad4b28d1416321e65.tar.gz
XS_Tie_Hash_NamedCapture_STORE should always croak on invalid parameters.
Previously, it would return undef instead of calling Perl_croak_no_modify() if PL_localizing was true. However, that case can never be reached. PL_localizing is set non-zero for 1: Perl_mg_localize and PL_save_scalar, for the duration of executing the local 2: Perl_leave_scope for the duration of unwinding the local However, XS_Tie_Hash_NamedCapture_STORE can't be reached in either case, with PL_curpm NULL (or otherwise invalid) || !SvROK(ST(0)). Case 1 would be the call to save_helem_flags() in pp_helem. However, this is only reached if preeminent is TRUE, which will only hold if hv_exists_ent() has already returned TRUE, which will only be possible if PL_curpm and ST(0) are valid. Case 2 would be the case SAVEt_HELEM in Perl_leave_scope(). However, this case is only reached as part of the unwinding from Case 1 above, so again PL_curpm and ST(0) will be valid, for this dynamic scope. This commit is the patch proposed in RT ##77610. It does not resolve all issues in that ticket. Currently C<local $1> is legal - it's a runtime no-op, which neither errors *nor* resets $1 to undef. Clearly C<local $+{k}> is inconsistent with this, (as it errors at scope exit for all cases, and additionally errors at local time if $+{k} exists) but I consider it not worth fixing until we decide whether C<local $1>'s current behaviour is a "bug" or a "feature".
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/universal.c b/universal.c
index e3e91cf539..5442f87e63 100644
--- a/universal.c
+++ b/universal.c
@@ -1307,10 +1307,7 @@ XS(XS_Tie_Hash_NamedCapture_STORE)
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
if (!rx || !SvROK(ST(0))) {
- if (!PL_localizing)
- Perl_croak_no_modify(aTHX);
- else
- XSRETURN_UNDEF;
+ Perl_croak_no_modify(aTHX);
}
SP -= items;