public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-5095] Fortran: frontend passes do_subscript leaks gmp memory [PR97345]
@ 2023-01-10 21:50 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2023-01-10 21:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fec9fc1a17ec44461cee841513f1b6b8ad680fe4

commit r13-5095-gfec9fc1a17ec44461cee841513f1b6b8ad680fe4
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Jan 10 22:41:17 2023 +0100

    Fortran: frontend passes do_subscript leaks gmp memory [PR97345]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/97345
            * frontend-passes.cc (do_subscript): Clear used gmp variables.

Diff:
---
 gcc/fortran/frontend-passes.cc | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc
index 612c12d233d..db2b98290d6 100644
--- a/gcc/fortran/frontend-passes.cc
+++ b/gcc/fortran/frontend-passes.cc
@@ -2892,7 +2892,12 @@ do_subscript (gfc_expr **e)
 
 		  cmp = mpz_cmp (do_end, do_start);
 		  if ((sgn > 0 && cmp < 0) || (sgn < 0 && cmp > 0))
-		    break;
+		    {
+		      mpz_clear (do_start);
+		      mpz_clear (do_end);
+		      mpz_clear (do_step);
+		      break;
+		    }
 		}
 
 	      /* May have to correct the end value if the step does not equal
@@ -2965,6 +2970,12 @@ do_subscript (gfc_expr **e)
 		      mpz_clear (val);
 		    }
 		}
+
+	      if (have_do_start)
+		mpz_clear (do_start);
+	      if (have_do_end)
+		mpz_clear (do_end);
+	      mpz_clear (do_step);
 	    }
 	}
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-10 21:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 21:50 [gcc r13-5095] Fortran: frontend passes do_subscript leaks gmp memory [PR97345] Harald Anlauf

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).