Skip to content

Commit

Permalink
trans-array.c (gfc_array_allocate, [...]): Plug memory leak.
Browse files Browse the repository at this point in the history
2013-07-22  Tobias Burnus  <[email protected]>

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

From-SVN: r201125
  • Loading branch information
tob2 authored and Tobias Burnus committed Jul 22, 2013
1 parent 859abdd commit 6a2bf10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions gcc/fortran/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2013-07-22 Tobias Burnus <[email protected]>

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

2013-07-21 Ondřej Bílka <[email protected]>

* trans-decl.c: Fix comment typos.
Expand Down
13 changes: 7 additions & 6 deletions gcc/fortran/trans-array.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 6a2bf10

Please sign in to comment.