diff mbox series

Fortran: fix two minor front-end GMP memleaks

Message ID trinity-a9a79370-22cd-441c-b937-f9ac1ceba009-1733693932847@trinity-msg-rest-gmx-gmx-live-548599f845-wgl9d
State New
Headers show
Series Fortran: fix two minor front-end GMP memleaks | expand

Commit Message

Harald Anlauf Dec. 8, 2024, 9:38 p.m. UTC
Dear all,

while looking at testcases with inquiry refs, I encountered two minor
GMP memleaks due to double-initialization of GMP variables.  Easily
plugged by the attached patch.

Regtested on x86_64-pc-linux-gnu.

I intend to commit as obvious within 24h unless there are objections.

Thanks,
Harald

Comments

Jerry D Dec. 8, 2024, 10:57 p.m. UTC | #1
Looks good, OK to push.

On Sun, Dec 8, 2024, 1:39 PM Harald Anlauf <anlauf@gmx.de> wrote:

> Dear all,
>
> while looking at testcases with inquiry refs, I encountered two minor
> GMP memleaks due to double-initialization of GMP variables.  Easily
> plugged by the attached patch.
>
> Regtested on x86_64-pc-linux-gnu.
>
> I intend to commit as obvious within 24h unless there are objections.
>
> Thanks,
> Harald
>
>
Harald Anlauf Dec. 9, 2024, 5:22 p.m. UTC | #2
Thanks, Jerry!

Pushed as r15-6053.

Am 08.12.24 um 23:57 schrieb Jerry Delisle:
> Looks good, OK to push.
> 
> On Sun, Dec 8, 2024, 1:39 PM Harald Anlauf <anlauf@gmx.de> wrote:
> 
>> Dear all,
>>
>> while looking at testcases with inquiry refs, I encountered two minor
>> GMP memleaks due to double-initialization of GMP variables.  Easily
>> plugged by the attached patch.
>>
>> Regtested on x86_64-pc-linux-gnu.
>>
>> I intend to commit as obvious within 24h unless there are objections.
>>
>> Thanks,
>> Harald
>>
>>
>
diff mbox series

Patch

From a299b38fa34869b19f5e11bcc389cd78c877c319 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Sun, 8 Dec 2024 22:30:32 +0100
Subject: [PATCH] Fortran: fix two minor front-end GMP memleaks

gcc/fortran/ChangeLog:

	* expr.cc (find_array_section): Do not initialize GMP variables
	twice.
---
 gcc/fortran/expr.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index a997bdae726..a349d989d6c 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -1613,7 +1613,7 @@  find_array_section (gfc_expr *expr, gfc_ref *ref)
 	  /* Zero-sized arrays have no shape and no elements, stop early.  */
 	  if (!begin->shape)
 	    {
-	      mpz_init_set_ui (nelts, 0);
+	      mpz_set_ui (nelts, 0);
 	      break;
 	    }

@@ -1714,7 +1714,7 @@  find_array_section (gfc_expr *expr, gfc_ref *ref)
      constructor.  */
   for (idx = 0; idx < (int) mpz_get_si (nelts); idx++)
     {
-      mpz_init_set_ui (ptr, 0);
+      mpz_set_ui (ptr, 0);

       incr_ctr = true;
       for (d = 0; d < rank; d++)
--
2.35.3