]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR32858 ld segfault on fuzzed object
authorAlan Modra <amodra@gmail.com>
Thu, 10 Apr 2025 10:11:49 +0000 (19:41 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 10 Apr 2025 10:15:59 +0000 (19:45 +0930)
We missed one place where it is necessary to check for empty groups.

PR 32858
* elflink.c (elf_gc_sweep): Protect against empty group.

bfd/elflink.c

index a76e8e38da728b41c47dfe89e1b97cf99a7bdb7b..549b7b7dd92ab94c2027b37aca0acc1f45de8428 100644 (file)
@@ -14408,7 +14408,8 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info)
          if (o->flags & SEC_GROUP)
            {
              asection *first = elf_next_in_group (o);
-             o->gc_mark = first->gc_mark;
+             if (first != NULL)
+               o->gc_mark = first->gc_mark;
            }
 
          if (o->gc_mark)