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] readelf/objdump remember_state memory leaks
Date: Fri,  9 Jun 2023 06:10:19 +0000 (GMT)	[thread overview]
Message-ID: <20230609061019.936613857357@sourceware.org> (raw)

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

commit ca5321d49ae1b6d1ec91d4ff79e85dc8ec30576a
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Jun 8 19:58:45 2023 +0930

    readelf/objdump remember_state memory leaks
    
            * dwarf.c (display_debug_frames <DW_CFA_restore_state>): Do free
            invalid remember_state.

Diff:
---
 binutils/dwarf.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 8a20bf2a349..4f695bf2bca 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -9823,12 +9823,14 @@ display_debug_frames (struct dwarf_section *section,
 		    {
 		      warn (_("Invalid column number in saved frame state\n"));
 		      fc->ncols = 0;
-		      break;
 		    }
-		  memcpy (fc->col_type, rs->col_type,
-			  rs->ncols * sizeof (*rs->col_type));
-		  memcpy (fc->col_offset, rs->col_offset,
-			  rs->ncols * sizeof (*rs->col_offset));
+		  else
+		    {
+		      memcpy (fc->col_type, rs->col_type,
+			      rs->ncols * sizeof (*rs->col_type));
+		      memcpy (fc->col_offset, rs->col_offset,
+			      rs->ncols * sizeof (*rs->col_offset));
+		    }
 		  free (rs->col_type);
 		  free (rs->col_offset);
 		  free (rs);

                 reply	other threads:[~2023-06-09  6:10 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=20230609061019.936613857357@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).