From patchwork Fri Feb 24 21:21:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 65627 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F0B9385087A for ; Fri, 24 Feb 2023 21:21:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-12.smtpout.orange.fr [80.12.242.12]) by sourceware.org (Postfix) with ESMTPS id A1E5C3857C45 for ; Fri, 24 Feb 2023 21:21:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1E5C3857C45 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orange.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=orange.fr Received: from [192.168.1.16] ([86.215.161.51]) by smtp.orange.fr with ESMTPA id VfVCptcPQ8UVdVfVOpFJjK; Fri, 24 Feb 2023 22:21:30 +0100 X-ME-Helo: [192.168.1.16] X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Fri, 24 Feb 2023 22:21:30 +0100 X-ME-IP: 86.215.161.51 Message-ID: <246d8ca0-b2a0-9c32-f79d-a9b86b26a0fd@orange.fr> Date: Fri, 24 Feb 2023 22:21:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 From: Mikael Morin Subject: [pushed] fortran: Plug leak of associated_dummy memory. [PR108923] To: gfortran , gcc-patches Content-Language: en-US X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hello, I have just pushed a for PR108923 (a memory leak). It fixes the small reproducer that I pasted in bugzilla, and I have run it through the fortran regression testsuite. More details in the patch. From 545a7d5da5fcc338e29c5241b574ac99d03f4454 Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Fri, 24 Feb 2023 22:11:17 +0100 Subject: [PATCH] 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. --- gcc/fortran/expr.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index c295721b9d6..4662328bf31 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; -- 2.39.1