This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
avoid SEGV with uninit warning with multideref
authorDavid Mitchell <davem@iabyn.com>
Wed, 10 Jul 2019 11:59:06 +0000 (12:59 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 10 Jul 2019 11:59:06 +0000 (12:59 +0100)
commit28eabf1185634216ca335b3a24e1131b0f392ca1
tree9ed231084a04636af79c060d1228e7d4d55c95b1
parentdc65f37092690cb834e2b1030cd905ed0a0066dd
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.
sv.c
t/lib/warnings/9uninit