public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: Re: Fix an aout memory leak
Date: Wed, 29 Mar 2023 09:50:48 +1030	[thread overview]
Message-ID: <ZCN2UKpjfEJJrAz4@squeak.grove.modra.org> (raw)

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

             reply	other threads:[~2023-03-28 23:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 23:20 Alan Modra [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-01-06 10:44 Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZCN2UKpjfEJJrAz4@squeak.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).