This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
change HvENAME_HEK() to HvENAME_HEK_NN() where NULLs would crash anyway
authorTony Cook <tony@develop-help.com>
Thu, 17 Nov 2022 03:41:35 +0000 (14:41 +1100)
committerJames E Keenan <jkeenan@cpan.org>
Fri, 18 Nov 2022 23:12:45 +0000 (18:12 -0500)
commit970609e17c79578d2051de18f156f48701755715
treed9de3ab70e16c64e9202bf197c299d514ecce8f8
parent2e4090b82403991910f1fe64866048b62ccf5402
change HvENAME_HEK() to HvENAME_HEK_NN() where NULLs would crash anyway

gcc 12 was producing a confusing message complaining that
references to with hek_key[] were beyond the end of the array,
even though a properly HEK has bytes beyond the first we declare.

From experimentation I theorize the confusing message was produced
because HvENAME_HEK() can return a NULL pointer, and the array
pointed to by any NULL pointer is zero length, producing the
array bounds warning we were seeing.

Fixed by changing each hv_(fetch|delete)hek() call to use the
HvENAME_HEK_NN() macro variant, which doesn't include an explicit
NULL return value.

mro_method_changed_in() was a bit special, it evaluated the
hv_fetchhek() before the check for an anonymous stash, so I reordered
the code to take advantage of C99, checking the assertions before we
dereference the stash pointer, checking we have a name before trying
to look it up.
hv.c
mro_core.c