public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Fix an aout memory leak
@ 2023-01-06 10:44 Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2023-01-06 10:44 UTC (permalink / raw)
  To: binutils

	* aoutx.h (aout_bfd_free_cached_info): Free line_buf.

diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index ae3e917c880..6d6527640fe 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -2909,6 +2909,7 @@ NAME (aout, bfd_free_cached_info) (bfd *abfd)
     return true;
 
 #define BFCI_FREE(x) do { free (x); x = NULL; } while (0)
+  BFCI_FREE (adata (abfd).line_buf);
   BFCI_FREE (obj_aout_symbols (abfd));
 #ifdef USE_MMAP
   obj_aout_external_syms (abfd) = 0;

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fix an aout memory leak
@ 2023-03-28 23:20 Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2023-03-28 23:20 UTC (permalink / raw)
  To: binutils

We have way too much duplicated code in bfd.  Apply dd3a3d0af9f6 and
920581c57e08 to pdp11.c.

	* pdp11.c (bfd_free_cached_info): Free line_buf.  Return true
	if tdata.aout_data is NULL.

diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index 862cf49fda3..9edbba92c82 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -2539,12 +2539,13 @@ NAME (aout, bfd_free_cached_info) (bfd *abfd)
 {
   asection *o;
 
-  if (bfd_get_format (abfd) != bfd_object)
+  if (bfd_get_format (abfd) != bfd_object
+      || abfd->tdata.aout_data == NULL)
     return true;
 
 #define BFCI_FREE(x) do { free (x); x = NULL; } while (0)
+  BFCI_FREE (adata (abfd).line_buf);
   BFCI_FREE (obj_aout_symbols (abfd));
-
 #ifdef USE_MMAP
   obj_aout_external_syms (abfd) = 0;
   bfd_free_window (&obj_aout_sym_window (abfd));

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-28 23:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-06 10:44 Fix an aout memory leak Alan Modra
2023-03-28 23:20 Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).