public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Set dwarf2 stash pointer earlier
Date: Mon,  9 Jan 2023 23:40:35 +0000 (GMT)	[thread overview]
Message-ID: <20230109234035.677063858414@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8eacd95dd4406ae4021a6996c0c505648da75440

commit 8eacd95dd4406ae4021a6996c0c505648da75440
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Jan 8 12:56:21 2023 +1030

    Set dwarf2 stash pointer earlier
    
    This fixes a memory leak in the vanishingly rare cases (found by
    fuzzers of course) when something goes wrong in the save_section_vma,
    htab_create_alloc or alloc_trie_leaf calls before *pinfo is written.
    If *pinfo is not written, _bfd_dwarf2_cleanup_debug_info won't be able
    to free that memory.
    
            * dwarf2.c (_bfd_dwarf2_slurp_debug_info): Save stash pointer
            on setting up stash.

Diff:
---
 bfd/dwarf2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index f689eebbd88..bd431805d2a 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -5408,6 +5408,7 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd,
       stash = (struct dwarf2_debug *) bfd_zalloc (abfd, amt);
       if (! stash)
 	return false;
+      *pinfo = stash;
     }
   stash->orig_bfd = abfd;
   stash->debug_sections = debug_sections;
@@ -5433,8 +5434,6 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd,
   if (!stash->alt.trie_root)
     return false;
 
-  *pinfo = stash;
-
   if (debug_bfd == NULL)
     debug_bfd = abfd;

                 reply	other threads:[~2023-01-09 23:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230109234035.677063858414@sourceware.org \
    --to=amodra@sourceware.org \
    --cc=bfd-cvs@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).