]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Segfault in _bfd_delete_bfd with USE_MMAP
authorAlan Modra <amodra@gmail.com>
Wed, 10 Apr 2024 23:55:13 +0000 (09:25 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 11 Apr 2024 00:02:10 +0000 (09:32 +0930)
Any of the calls to _bfd_delete_bfd in bfd_fopen will hit this.

* opncls.c (_bfd_delete_bfd): Check for non-NULL xvec before
accessing flavour.

bfd/opncls.c

index 2f8a3a6c9191fd2cb6cc2975c83f3677e9c488fa..bc76696dfdbc497c29d44dca3383ce5f5c64f8ee 100644 (file)
@@ -164,7 +164,8 @@ static void
 _bfd_delete_bfd (bfd *abfd)
 {
 #ifdef USE_MMAP
-  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+  if (abfd->xvec
+      && abfd->xvec->flavour == bfd_target_elf_flavour)
     {
       asection *sec;
       for (sec = abfd->sections; sec != NULL; sec = sec->next)