public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Subject: [PATCH v2 1/4] x86: don't leak sub-architecture accumulated strings
Date: Tue, 5 Jul 2022 08:44:13 +0200	[thread overview]
Message-ID: <4926bfce-8539-64a2-f7c6-dde49fa74456@suse.com> (raw)
In-Reply-To: <eaec341a-2b6f-5522-7258-171d6d1d77d7@suse.com>

While it may not be necessary in i386_target_format() (but then setting
the variable to NULL also wouldn't be necessary), at least in the other
cases strings may already have accumulated.
---
v2: Use free() (hesitantly).

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2738,6 +2738,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 		  check_cpu_arch_compatible (string, cpu_arch[j].flags);
 
 		  cpu_arch_name = cpu_arch[j].name;
+		  free (cpu_sub_arch_name);
 		  cpu_sub_arch_name = NULL;
 		  cpu_arch_flags = cpu_arch[j].flags;
 		  if (flag_code == CODE_64BIT)
@@ -13236,6 +13237,7 @@ md_parse_option (int c, const char *arg)
 		    continue;
 
 		  cpu_arch_name = cpu_arch[j].name;
+		  free (cpu_sub_arch_name);
 		  cpu_sub_arch_name = NULL;
 		  cpu_arch_flags = cpu_arch[j].flags;
 		  cpu_arch_isa = cpu_arch[j].type;
@@ -13899,6 +13901,7 @@ i386_target_format (void)
 	{
 	  static const i386_cpu_flags iamcu_flags = CPU_IAMCU_FLAGS;
 	  cpu_arch_name = "iamcu";
+	  free (cpu_sub_arch_name);
 	  cpu_sub_arch_name = NULL;
 	  cpu_arch_flags = iamcu_flags;
 	  cpu_arch_isa = PROCESSOR_IAMCU;


  reply	other threads:[~2022-07-05  6:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05  6:42 [PATCH v2 0/4] gas/x86: .arch / -march= enhancements Jan Beulich
2022-07-05  6:44 ` Jan Beulich [this message]
2022-07-05  6:44 ` [PATCH v2 2/4] x86: permit "default" with .arch Jan Beulich
2022-07-05  6:45 ` [PATCH v2 3/4] x86: generalize disabling of sub-architectures Jan Beulich
2022-07-05  6:45 ` [PATCH v2 4/4] x86: introduce a state stack for .arch Jan Beulich
2022-07-05 15:34 ` [PATCH v2 0/4] gas/x86: .arch / -march= enhancements H.J. Lu

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=4926bfce-8539-64a2-f7c6-dde49fa74456@suse.com \
    --to=jbeulich@suse.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).