Re: bfd_close and target free_cached_memory
authorAlan Modra <amodra@gmail.com>
Thu, 1 Jun 2023 23:30:41 +0000 (09:00 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 2 Jun 2023 00:11:49 +0000 (09:41 +0930)
_bfd_delete_bfd can be called early, before the target xvec is set up.

* opncls.c (_bfd_delete_bfd): Don't segfault on NULL xvec.

bfd/opncls.c

index b0c23b4201cdbd5713342f4d0374194eeb12666f..7cb09a108e5ca90e641aa94f9949ae1a3cb43e0e 100644 (file)
@@ -157,7 +157,7 @@ static void
 _bfd_delete_bfd (bfd *abfd)
 {
   /* Give the target _bfd_free_cached_info a chance to free memory.  */
-  if (abfd->memory)
+  if (abfd->memory && abfd->xvec)
     bfd_free_cached_info (abfd);
 
   /* The target _bfd_free_cached_info may not have done anything..  */