From: H.J. Lu <hjl@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] gas: Fix a CFI label name memory leak in scfi.c
Date: Thu, 11 Apr 2024 11:11:24 +0000 (GMT) [thread overview]
Message-ID: <20240411111124.7DEB0384AB49@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cafca5eaa068eaaa3e3a2ffab356efb4714c2968
commit cafca5eaa068eaaa3e3a2ffab356efb4714c2968
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Apr 9 16:04:16 2024 -0700
gas: Fix a CFI label name memory leak in scfi.c
CFI label name can be freed only after use.
* scfi.c (handle_scfi_dot_cfi): Free CFI label name after use.
* scfidw2gen.c (scfi_process_cfi_label): Add a comment. Remove
TODO on freeing CFI label name.
Diff:
---
gas/scfi.c | 1 +
gas/scfidw2gen.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gas/scfi.c b/gas/scfi.c
index 929ea8a73e1..b29e922ecb3 100644
--- a/gas/scfi.c
+++ b/gas/scfi.c
@@ -1141,6 +1141,7 @@ handle_scfi_dot_cfi (ginsnS *ginsn)
break;
case CFI_label:
scfi_dot_cfi (CFI_label, 0, 0, 0, op->op_data->name, ginsn->sym);
+ free ((char *) op->op_data->name);
break;
case CFI_signal_frame:
scfi_dot_cfi (CFI_signal_frame, 0, 0, 0, NULL, ginsn->sym);
diff --git a/gas/scfidw2gen.c b/gas/scfidw2gen.c
index ebf2d24dab2..2b018fac8bd 100644
--- a/gas/scfidw2gen.c
+++ b/gas/scfidw2gen.c
@@ -57,8 +57,8 @@ scfi_process_cfi_label (void)
frch_ginsn_data_append (ginsn);
scfi_op_add_cfi_label (ginsn, name);
- /* TODO. */
- // free (name);
+ /* NB: Can't free NAME here since it will be used later. Free it in
+ handle_scfi_dot_cfi after it is unused. */
demand_empty_rest_of_line ();
}
reply other threads:[~2024-04-11 11:11 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=20240411111124.7DEB0384AB49@sourceware.org \
--to=hjl@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).