summaryrefslogtreecommitdiff
path: root/t/op/tie.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-10-28 01:48:18 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-10-28 02:04:59 -0700
commitac9f75b57c64f1cbeaf0caa63e0962e19df8d71a (patch)
tree4a503d255c72b2a2961c10d420d3ba91f6f07284 /t/op/tie.t
parent0960ff5ae77d081b538d8f0690367bb5144cf1c1 (diff)
downloadperl-ac9f75b57c64f1cbeaf0caa63e0962e19df8d71a.tar.gz
Don’t crash with $tied[-1] when array is tied to non-obj
The code for checking to see whether $NEGATIVE_INDICES is defined in the tie package was very fragile, and was repeated four times.
Diffstat (limited to 't/op/tie.t')
-rw-r--r--t/op/tie.t15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/op/tie.t b/t/op/tie.t
index 83f10dd5ac..ad58af74c0 100644
--- a/t/op/tie.t
+++ b/t/op/tie.t
@@ -1317,3 +1317,18 @@ EXPECT
does 1 exist?
does 49 exist?
does -1 exist?
+########
+
+# Crash when using negative index on array tied to non-object
+sub TIEARRAY{bless[]};
+${\tie @a, ""} = undef;
+eval { $_ = $a[-1] }; print $@;
+eval { $a[-1] = '' }; print $@;
+eval { delete $a[-1] }; print $@;
+eval { exists $a[-1] }; print $@;
+
+EXPECT
+Can't call method "FETCHSIZE" on an undefined value at - line 5.
+Can't call method "FETCHSIZE" on an undefined value at - line 6.
+Can't call method "FETCHSIZE" on an undefined value at - line 7.
+Can't call method "FETCHSIZE" on an undefined value at - line 8.