diff options
author | David Mitchell <davem@iabyn.com> | 2019-07-10 12:59:06 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2019-07-10 12:59:06 +0100 |
commit | 28eabf1185634216ca335b3a24e1131b0f392ca1 (patch) | |
tree | 9ed231084a04636af79c060d1228e7d4d55c95b1 /t | |
parent | dc65f37092690cb834e2b1030cd905ed0a0066dd (diff) | |
download | perl-28eabf1185634216ca335b3a24e1131b0f392ca1.tar.gz |
avoid SEGV with uninit warning with multideref
RT #134275
When the 'uninitialized warning' code in S_find_uninit_var() comes
across an OP_MULTIDEREF node, it scans it to see if any part of that op
(e.g. the indices or the returned value) could have been the source of
the uninitialized value which triggered the warning. Unfortunately when
getting an AV or HV from a GV, it wasn't checking whether gp_av/gp_hv
contained a NULL value. If so, it would SEGV.
The test code is a bit contrived; you have to "pull the rug" from under
the GV at just the right moment with *foo = *bar, then trigger an uninit
warning on an op whose subtree includes an OP_MULTIDEREF.
Diffstat (limited to 't')
-rw-r--r-- | t/lib/warnings/9uninit | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit index 774c6ee432..5c173fdb2a 100644 --- a/t/lib/warnings/9uninit +++ b/t/lib/warnings/9uninit @@ -2206,3 +2206,13 @@ use warnings 'uninitialized'; undef $0; EXPECT Use of uninitialized value in undef operator at - line 5. +######## +# RT #134275 +# This was SEGVing due to the multideref code in S_find_uninit_var not +# handling a GV with a null gp_hv slot. +use warnings 'uninitialized'; +"" =~ /$foo{a}${*foo=*bar}$x/; +EXPECT +Use of uninitialized value in regexp compilation at - line 5. +Use of uninitialized value in regexp compilation at - line 5. +Use of uninitialized value $x in regexp compilation at - line 5. |