summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2021-09-22 11:47:55 +1000
committerTony Cook <tony@develop-help.com>2021-09-22 11:47:55 +1000
commit23cca2d1f4544cb47f1124d98c308ce1f31f09a6 (patch)
tree3323e0b808e1ccc9a621bc4e74c29139188e9b58 /t
parentfa26526789fbf61d704bd6291823c16ed912f342 (diff)
downloadperl-23cca2d1f4544cb47f1124d98c308ce1f31f09a6.tar.gz
Don't try to Sv[PI]V() on an undef index SV in find_uninit_var()
When trying to evaluate: $x{$y} or $x[$y] where both the index and the hash or array entry was undefined, when trying to report the entry as uninitialised, find_uninit_var() would try to get the string or numeric value of the index, recursively trying to produce a warning. This would end up overflowing the stack, producing a segmentation fault. Fixes #19147.
Diffstat (limited to 't')
-rw-r--r--t/lib/warnings/sv13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/lib/warnings/sv b/t/lib/warnings/sv
index be04b8457e..8524c2c25a 100644
--- a/t/lib/warnings/sv
+++ b/t/lib/warnings/sv
@@ -211,6 +211,19 @@ Use of uninitialized value $a in join or string at - line 4.
Use of uninitialized value $a in concatenation (.) or string at - line 5.
Use of uninitialized value $a in concatenation (.) or string at - line 6.
########
+# NAME https://github.com/Perl/perl5/issues/19147
+use warnings 'uninitialized';
+my %x;
+my @z;
+my $y;
+-$x{$y};
+-$z[$y];
+EXPECT
+Use of uninitialized value $y in hash element at - line 5.
+Use of uninitialized value $x{""} in negation (-) at - line 5.
+Use of uninitialized value $y in array element at - line 6.
+Use of uninitialized value $z[0] in negation (-) at - line 6.
+########
# sv.c
use warnings 'numeric' ;
sub TIESCALAR{bless[]} ;