This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #81750] Perl 5.12: undef-as-hashref bug
authorFather Chrysostomos <sprout@cpan.org>
Fri, 21 Jan 2011 16:26:50 +0000 (08:26 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 21 Jan 2011 16:29:30 +0000 (08:29 -0800)
commitfd1d9b5c785ad0e5340c74dd6f1be27a3735e829
treef6509401b32a2abf51feebd28ca358bf2d28752b
parentc0f8aaaaa842ec59ffd5f565760f0c9f7cfd674f
[perl #81750] Perl 5.12: undef-as-hashref bug

The addition of the boolkeys op type in commit 867fa1e2d did not
account for the fact that rv2hv (%{}) can sometimes return undef
(%$undef with strict refs turned off).

When the boolkeys op is created (and the rv2hv becomes its kid), the
rv2hv is flagged with OPf_REF, meaning that it must return a hash, not
the contents.

Perl_softrefxv in pp.c checks for that flag. If it is set, it dies
with ‘Can't use an undefined value as a HASH reference’ for unde-
fined values.

This commit changes it to make an exception if rv2hv->op_next is a
boolkeys op. It also changes pp_boolkeys to account for undef.
pp.c
t/op/ref.t