]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR 33697, fuzzer segfault
authorAlan Modra <amodra@gmail.com>
Mon, 8 Dec 2025 05:28:33 +0000 (15:58 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 8 Dec 2025 09:23:35 +0000 (19:53 +1030)
PR 33697
* readelf.c (process_relocs): Don't segfault on no sections.

binutils/readelf.c

index 1bd9afa1ec1ebb11a201cb493d361a78ab86a936..b3f59aa21283ca6b15ef131f43e8ea98754c7fb6 100644 (file)
@@ -10048,13 +10048,11 @@ process_relocs (Filedata * filedata)
       size_t i;
       bool found = false;
 
-      for (i = 0, section = filedata->section_headers;
-          i < filedata->file_header.e_shnum;
-          i++, section++)
-       {
+      section = filedata->section_headers;
+      if (section != NULL)
+       for (i = 0; i < filedata->file_header.e_shnum; i++, section++)
          if (display_relocations (section, filedata, do_reloc))
            found = true;
-       }
 
       if (do_reloc && ! found)
        {