[binutils-gdb] Re: bfd_close and target free_cached_memory
Alan Modra
amodra@sourceware.org
Fri Jun 2 00:12:24 GMT 2023
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=63188cb5c3e2814d6527d0309af4db8634e8cdaa
commit 63188cb5c3e2814d6527d0309af4db8634e8cdaa
Author: Alan Modra <amodra@gmail.com>
Date: Fri Jun 2 09:00:41 2023 +0930
Re: bfd_close and target free_cached_memory
_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.
Diff:
---
bfd/opncls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bfd/opncls.c b/bfd/opncls.c
index b0c23b4201c..7cb09a108e5 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -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.. */
More information about the Binutils-cvs
mailing list