public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] PR32032 dwp segfaults on hello world binary
Date: Mon, 29 Jul 2024 10:25:40 +0000 (GMT)	[thread overview]
Message-ID: <20240729102540.C558E385841E@sourceware.org> (raw)

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

commit 972092a9eda941a5744125f79fe58e52fb7007e4
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Jul 29 14:25:07 2024 +0930

    PR32032 dwp segfaults on hello world binary
    
    Fixing the segfault is easy with this bandaid, but further work is
    needed to teach dwp about DW_AT_dwo_name and dwo id in the cu header.
    At the moment dwp only handles DW_AT_GNU_dwo_name and DW_AT_GNU_dwo_id.
    
            PR 32032
            * dwp.cc (Dwp_output_file::finalize): Return immediately on
            no output file.

Diff:
---
 gold/dwp.cc | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gold/dwp.cc b/gold/dwp.cc
index e1656d0650d..584892c2b0c 100644
--- a/gold/dwp.cc
+++ b/gold/dwp.cc
@@ -1838,6 +1838,9 @@ Dwp_output_file::finalize()
 {
   unsigned char* buf;
 
+  if (this->fd_ == NULL)
+    return;
+
   // Write the accumulated output sections.
   for (unsigned int i = 0; i < this->sections_.size(); i++)
     {
@@ -1919,11 +1922,8 @@ Dwp_output_file::finalize()
   this->write_ehdr();
 
   // Close the file.
-  if (this->fd_ != NULL)
-    {
-      if (::fclose(this->fd_) != 0)
-	gold_fatal(_("%s: %s"), this->name_, strerror(errno));
-    }
+  if (::fclose(this->fd_) != 0)
+    gold_fatal(_("%s: %s"), this->name_, strerror(errno));
   this->fd_ = NULL;
 }

                 reply	other threads:[~2024-07-29 10:25 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=20240729102540.C558E385841E@sourceware.org \
    --to=amodra@sourceware.org \
    --cc=binutils-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).