* [PATCH] Plug memory leak in attribute target_clones
@ 2022-11-03 21:00 Bernhard Reutner-Fischer
2022-11-05 11:13 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Bernhard Reutner-Fischer @ 2022-11-03 21:00 UTC (permalink / raw)
To: gcc-patches
Cc: Bernhard Reutner-Fischer, Bernhard Reutner-Fischer, Martin Liska
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Plug memory leak in attribute target_clones
2022-11-03 21:00 [PATCH] Plug memory leak in attribute target_clones Bernhard Reutner-Fischer
@ 2022-11-05 11:13 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-11-05 11:13 UTC (permalink / raw)
To: Bernhard Reutner-Fischer; +Cc: gcc-patches, Bernhard Reutner-Fischer
On Thu, Nov 3, 2022 at 10:01 PM Bernhard Reutner-Fischer via
Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>
> It looks like there was some memory leak in the handling
> of attribute target_clones, introduced in 5928bc2ec06d .
>
> Ok for trunk if testing passes?
OK
> 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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-05 11:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 21:00 [PATCH] Plug memory leak in attribute target_clones Bernhard Reutner-Fischer
2022-11-05 11:13 ` Richard Biener
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).