]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix for -Wstringop-overflow false positive
authorMichael Matz <matz@suse.de>
Thu, 17 Oct 2024 15:42:40 +0000 (17:42 +0200)
committerMichael Matz <matz@suse.de>
Thu, 17 Oct 2024 15:44:29 +0000 (17:44 +0200)
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.

bfd/merge.c

index c811bc57eae617f71c630d4b9de912315d011662..abb0269227eb7c7c3fd8d271397242a0f8f75311 100644 (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));