Fix for -Wstringop-overflow false positive

the way the overflow check was written wasn't understood by some
GCC versions and produced false positives for the memset call being
called potentially with object sizes that are larger than half
address-space.
This commit is contained in:
Michael Matz
2024-10-17 17:42:40 +02:00
parent ed3228de9b
commit 22ae2e1f70

View File

@@ -181,9 +181,9 @@ sec_merge_maybe_resize (struct sec_merge_hash *table, unsigned added)
do
{
newnb *= 2;
if (!(unsigned int)newnb)
if (newnb >> (8 * sizeof(mapofs_type) - 1))
return false;
newnb *= 2;
}
while (NEEDS_RESIZE (bfdtab->count + added, newnb));