This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #128086] Fix precedence in hv_ename_delete
authorHugo van der Sanden <hv@crypt.org>
Sun, 15 May 2016 20:48:58 +0000 (13:48 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 15 May 2016 21:01:29 +0000 (14:01 -0700)
A stash’s array of names may have null for the first entry, in which
case it is not one of the effective names, and the name count will
be negative.

The ‘count > 0’ is meant to prevent hv_ename_delete from trying to
read that entry, but a precedence problem introduced in 4643eb699
stopped it from doing that.

[This commit message was written by the committer.]

hv.c

diff --git a/hv.c b/hv.c
index 7b5ad95..5523475 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -2476,9 +2476,10 @@ Perl_hv_ename_delete(pTHX_ HV *hv, const char *name, U32 len, U32 flags)
                return;
            }
        if (
-           count > 0 && (HEK_UTF8(*namep) || (flags & SVf_UTF8)) 
+           count > 0 && ((HEK_UTF8(*namep) || (flags & SVf_UTF8)) 
                 ? hek_eq_pvn_flags(aTHX_ *namep, name, (I32)len, flags)
                : (HEK_LEN(*namep) == (I32)len && memEQ(HEK_KEY(*namep), name, len))
+            )
        ) {
            aux->xhv_name_count = -count;
        }