From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>,
Bernhard Reutner-Fischer <aldot@gcc.gnu.org>,
Martin Liska <mliska@suse.cz>
Subject: [PATCH] Plug memory leak in attribute target_clones
Date: Thu, 3 Nov 2022 22:00:49 +0100 [thread overview]
Message-ID: <20221103210049.516886-1-aldot@gcc.gnu.org> (raw)
It looks like there was some memory leak in the handling
of attribute target_clones, introduced in 5928bc2ec06d .
Ok for trunk if testing passes?
gcc/ChangeLog:
* multiple_target.cc (expand_target_clones): Free memory.
Signed-off-by: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
---
gcc/multiple_target.cc | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/gcc/multiple_target.cc b/gcc/multiple_target.cc
index 67866a7c963..77e0f21dd05 100644
--- a/gcc/multiple_target.cc
+++ b/gcc/multiple_target.cc
@@ -390,19 +390,23 @@ expand_target_clones (struct cgraph_node *node, bool definition)
for (i = 0; i < attrnum; i++)
{
char *attr = attrs[i];
- char *suffix = XNEWVEC (char, strlen (attr) + 1);
- create_new_asm_name (attr, suffix);
/* Create new target clone. */
tree attributes = make_attribute ("target", attr,
DECL_ATTRIBUTES (node->decl));
+ char *suffix = XNEWVEC (char, strlen (attr) + 1);
+ create_new_asm_name (attr, suffix);
cgraph_node *new_node = create_target_clone (node, definition, suffix,
attributes);
+ XDELETEVEC (suffix);
if (new_node == NULL)
- return false;
+ {
+ XDELETEVEC (attrs);
+ XDELETEVEC (attr_str);
+ return false;
+ }
new_node->local = false;
- XDELETEVEC (suffix);
decl2_v = new_node->function_version ();
if (decl2_v != NULL)
--
2.38.1
next reply other threads:[~2022-11-03 21:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 21:00 Bernhard Reutner-Fischer [this message]
2022-11-05 11:13 ` Richard Biener
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=20221103210049.516886-1-aldot@gcc.gnu.org \
--to=rep.dot.nop@gmail.com \
--cc=aldot@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=mliska@suse.cz \
/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).