Patchwork [Fortran,committed] Free temporary variables

login
register
mail settings
Submitter Tobias Burnus
Date Aug. 27, 2012, 8:52 p.m.
Message ID <503BDE11.2040808@net-b.de>
Download mbox | patch
Permalink /patch/180279/
State New
Headers show

Comments

Tobias Burnus - Aug. 27, 2012, 8:52 p.m.
Another obvious leakage fix: For "if( e1 == NULL || e2 == NULL)" one has 
to free the non-NULL expression (if there is one). Similarly, vector of 
type "tree *" has to be freed - we only need the elements of that vector.

Build and tested on x86-64-linux.
Committed as Rev. 190731

Tobias

Patch

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 190730)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,6 +1,13 @@ 
 2012-08-27  Tobias Burnus  <burnus@net-b.de>
 
 	PR fortran/54384
+	* resolve.c (gfc_resolve_character_operator): Free temporary
+	variables.
+	* trans-expr.c (gfc_conv_statement_function): Ditto.
+
+2012-08-27  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/54384
 	* dependency.c (check_section_vs_section): Use gfc_free_expr
 	instead of free.
 	* trans-intrinsic.c (conv_generic_with_optional_char_arg): Use
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(Revision 190730)
+++ gcc/fortran/resolve.c	(Arbeitskopie)
@@ -5593,7 +5593,12 @@  gfc_resolve_character_operator (gfc_expr *e)
   e->ts.u.cl = gfc_new_charlen (gfc_current_ns, NULL);
 
   if (!e1 || !e2)
-    return;
+    {
+      gfc_free_expr (e1);
+      gfc_free_expr (e2);
+      
+      return;
+    }
 
   e->ts.u.cl->length = gfc_add (e1, e2);
   e->ts.u.cl->length->ts.type = BT_INTEGER;
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c	(Revision 190730)
+++ gcc/fortran/trans-expr.c	(Arbeitskopie)
@@ -5080,6 +5080,7 @@  gfc_conv_statement_function (gfc_se * se, gfc_expr
   /* Restore the original variables.  */
   for (fargs = sym->formal, n = 0; fargs; fargs = fargs->next, n++)
     gfc_restore_sym (fargs->sym, &saved_vars[n]);
+  free (temp_vars);
   free (saved_vars);
 }