diff options
author | Father Chrysostomos <sprout@cpan.org> | 2015-03-11 23:11:30 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2015-03-11 23:32:35 -0700 |
commit | 3d50185de85a756293c9c3954114bd5c2d08a460 (patch) | |
tree | 3a17b96272781602c690d1d43ab5caa6c09dff91 /hv.c | |
parent | 9409f752f9f55770d0998b79e3e5a79b1153b46c (diff) | |
download | perl-3d50185de85a756293c9c3954114bd5c2d08a460.tar.gz |
[perl #123847] crash with *foo::=*bar::=*with_hash
When a hash has no canonical name and one effective name, the array of
names has a null pointer at the beginning. hv_ename_add was not tak-
ing that into account, and was trying to dereference the null pointer.
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -2314,10 +2314,12 @@ Perl_hv_ename_add(pTHX_ HV *hv, const char *name, U32 len, U32 flags) PERL_HASH(hash, name, len); if (aux->xhv_name_count) { - HEK ** const xhv_name = aux->xhv_name_u.xhvnameu_names; I32 count = aux->xhv_name_count; - HEK **hekp = xhv_name + (count < 0 ? -count : count); + HEK ** const xhv_name = aux->xhv_name_u.xhvnameu_names + (count<0); + HEK **hekp = xhv_name + (count < 0 ? -count - 1 : count); while (hekp-- > xhv_name) + { + assert(*hekp); if ( (HEK_UTF8(*hekp) || (flags & SVf_UTF8)) ? hek_eq_pvn_flags(aTHX_ *hekp, name, (I32)len, flags) @@ -2327,6 +2329,7 @@ Perl_hv_ename_add(pTHX_ HV *hv, const char *name, U32 len, U32 flags) aux->xhv_name_count = -count; return; } + } if (count < 0) aux->xhv_name_count--, count = -count; else aux->xhv_name_count++; Renew(aux->xhv_name_u.xhvnameu_names, count + 1, HEK *); |