[binutils-gdb] PR 33210 NULL pointer arithmetic in coffcode.h

Alan Modra amodra@sourceware.org
Fri Jul 25 02:19:44 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=626987854890e7a0b7479e5b33f1c24459b219cd

commit 626987854890e7a0b7479e5b33f1c24459b219cd
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jul 25 08:48:20 2025 +0930

    PR 33210 NULL pointer arithmetic in coffcode.h
    
    Fix ubsan "runtime error: applying zero offset to null pointer".

Diff:
---
 bfd/coffcode.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index b81195dd2ec..a2ee0362256 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -909,7 +909,9 @@ fill_comdat_hash (bfd *abfd)
   if (! _bfd_coff_get_external_symbols (abfd))
     return true;
 
-  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
+  esymstart = esym = obj_coff_external_syms (abfd);
+  if (esym == NULL)
+    return true;
   esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
 
   for (struct internal_syment isym;


More information about the Binutils-cvs mailing list