public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Mikael Morin <mikael@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-9243] fortran: Plug leak of associated_dummy memory. [PR108923]
Date: Sun, 12 Mar 2023 10:48:29 +0000 (GMT) [thread overview]
Message-ID: <20230312104829.B523C3858D1E@sourceware.org> (raw)
https://gcc.gnu.org/g:cd65c727fd6d5a252964dbeb3a735daa0a521a89
commit r12-9243-gcd65c727fd6d5a252964dbeb3a735daa0a521a89
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Fri Feb 24 22:11:17 2023 +0100
fortran: Plug leak of associated_dummy memory. [PR108923]
This fixes a memory leak by accompanying the release of
gfc_actual_arglist elements' memory with a release of the
associated_dummy field memory (if allocated).
Actual argument copy is adjusted as well so that each copy can free
its field independently.
PR fortran/108923
gcc/fortran/ChangeLog:
* expr.cc (gfc_free_actual_arglist): Free associated_dummy
memory.
(gfc_copy_actual_arglist): Make a copy of the associated_dummy
field if it is set in the original element.
(cherry picked from commit 24c9edfa73632276d7698c103f35833f29804d98)
Diff:
---
gcc/fortran/expr.cc | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 15d41d023d3..1369f25011f 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -545,6 +545,7 @@ gfc_free_actual_arglist (gfc_actual_arglist *a1)
a2 = a1->next;
if (a1->expr)
gfc_free_expr (a1->expr);
+ free (a1->associated_dummy);
free (a1);
a1 = a2;
}
@@ -565,6 +566,12 @@ gfc_copy_actual_arglist (gfc_actual_arglist *p)
new_arg = gfc_get_actual_arglist ();
*new_arg = *p;
+ if (p->associated_dummy != NULL)
+ {
+ new_arg->associated_dummy = gfc_get_dummy_arg ();
+ *new_arg->associated_dummy = *p->associated_dummy;
+ }
+
new_arg->expr = gfc_copy_expr (p->expr);
new_arg->next = NULL;
reply other threads:[~2023-03-12 10:48 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=20230312104829.B523C3858D1E@sourceware.org \
--to=mikael@gcc.gnu.org \
--cc=gcc-cvs@gcc.gnu.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).