]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
trans-array.c (gfc_array_allocate, [...]): Plug memory leak.
authorTobias Burnus <burnus@net-b.de>
Mon, 22 Jul 2013 13:03:50 +0000 (15:03 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Mon, 22 Jul 2013 13:03:50 +0000 (15:03 +0200)
2013-07-22  Tobias Burnus  <burnus@net-b.de>

        * trans-array.c (gfc_array_allocate,
        gfc_trans_deferred_array): Plug memory leak.

From-SVN: r201125

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c

index 85dc3c84e210dcd7225f373a4b46151f6c4374ea..b75ffc249c554719eb13a33d8c321236a0d78fe9 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-22  Tobias Burnus  <burnus@net-b.de>
+
+       * trans-array.c (gfc_array_allocate,
+       gfc_trans_deferred_array): Plug memory leak.
+
 2013-07-21   Ondřej Bílka  <neleai@seznam.cz>
 
        * trans-decl.c: Fix comment typos.
index 5cc174fa7ca6dd84061dc66327f37c228d8da521..5bcd67ddd5933aaac8b12cdb0670a55d6a110ae8 100644 (file)
@@ -5209,7 +5209,7 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
                              &se->pre, &set_descriptor_block, &overflow,
                              expr3_elem_size, nelems, expr3, ts);
 
-  if (dimension)
+  if (status == NULL_TREE && dimension)
     {
 
       var_overflow = gfc_create_var (integer_type_node, "overflow");
@@ -5223,8 +5223,7 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
       error = build_call_expr_loc (input_location, gfor_fndecl_runtime_error,
                                   1, msg);
     }
-
-  if (status != NULL_TREE)
+  else if (status != NULL_TREE)
     {
       tree status_type = TREE_TYPE (status);
       stmtblock_t set_status_block;
@@ -8525,10 +8524,12 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
       && !sym->attr.save && !sym->attr.result
       && !sym->ns->proc_name->attr.is_main_program)
     {
+      gfc_expr *e;
+      e = has_finalizer ? gfc_lval_expr_from_sym (sym) : NULL;
       tmp = gfc_trans_dealloc_allocated (sym->backend_decl,
-                                        sym->attr.codimension,
-                                        has_finalizer
-                                        ? gfc_lval_expr_from_sym (sym) : NULL);
+                                        sym->attr.codimension, e);
+      if (e)
+       gfc_free_expr (e);
       gfc_add_expr_to_block (&cleanup, tmp);
     }