summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-12-10 14:54:13 -0800
committerFather Chrysostomos <sprout@cpan.org>2010-12-10 16:09:32 -0800
commit6d1f0892ce0bd77f843552ab189aa5f121c374d4 (patch)
tree94a3bfc018033cdfc63ddd2519c51063f9498333 /sv.c
parent98be99db6ff47327a7754b282e66c6be7eb35bb6 (diff)
downloadperl-6d1f0892ce0bd77f843552ab189aa5f121c374d4.tar.gz
[perl #72090] unitialized variable name wrong with no strict refs
$ ./perl -we '$a = @$a > 0' Use of uninitialized value $a in array dereference at -e line 1. Use of uninitialized value $a in numeric gt (>) at -e line 1. S_find_uninit_var was not taking into account that rv2*v could return undef. So it merrily looked at the child ops to find one that named a variable. This commit makes it skip any rv2av/rv2hv that does not have an OP_GV as its child op. In other words, it skips @{...} and %{...} (including the shorthand forms @$foo and %$foo), but not @foo or %foo.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index c0c2458191..2cabf7be06 100644
--- a/sv.c
+++ b/sv.c
@@ -14031,6 +14031,12 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv,
if ( (type == OP_CONST && SvOK(cSVOPx_sv(kid)))
|| (type == OP_NULL && ! (kid->op_flags & OPf_KIDS))
|| (type == OP_PUSHMARK)
+ || (
+ /* @$a and %$a, but not @a or %a */
+ (type == OP_RV2AV || type == OP_RV2HV)
+ && cUNOPx(kid)->op_first
+ && cUNOPx(kid)->op_first->op_type != OP_GV
+ )
)
continue;
}