diff options
author | Tobias Burnus <burnus@net-b.de> | 2012-05-31 16:28:41 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2012-05-31 16:28:41 +0200 |
commit | cc2442cd78651d159418ac8e739bfc93f925ab2b (patch) | |
tree | e846e9933f57a2aeba1815dfb53f4e52db63c2cb | |
parent | 88af7c1a3b6b85c6528c7411938925acc7579899 (diff) | |
download | gcc-cc2442cd78651d159418ac8e739bfc93f925ab2b.zip gcc-cc2442cd78651d159418ac8e739bfc93f925ab2b.tar.gz gcc-cc2442cd78651d159418ac8e739bfc93f925ab2b.tar.bz2 |
re PR fortran/53521 (Memory leak with zero-sized array constructor)
2012-05-31 Tobias Burnus <burnus@net-b.de>
PR fortran/53521
* trans.c (gfc_deallocate_scalar_with_status): Properly
handle the case size == 0.
From-SVN: r188062
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans.c | 14 |
2 files changed, 7 insertions, 13 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e2b1ec3..39a3721 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2012-05-31 Tobias Burnus <burnus@net-b.de> + + PR fortran/53521 + * trans.c (gfc_deallocate_scalar_with_status): Properly + handle the case size == 0. + 2012-05-30 Tobias Burnus <burnus@net-b.de> PR c/53502 diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index 5d6e6ef..3313be9 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -1130,15 +1130,12 @@ internal_realloc (void *mem, size_t size) if (!res && size != 0) _gfortran_os_error ("Allocation would exceed memory limit"); - if (size == 0) - return NULL; - return res; } */ tree gfc_call_realloc (stmtblock_t * block, tree mem, tree size) { - tree msg, res, nonzero, zero, null_result, tmp; + tree msg, res, nonzero, null_result, tmp; tree type = TREE_TYPE (mem); size = gfc_evaluate_now (size, block); @@ -1169,15 +1166,6 @@ gfc_call_realloc (stmtblock_t * block, tree mem, tree size) build_empty_stmt (input_location)); gfc_add_expr_to_block (block, tmp); - /* if (size == 0) then the result is NULL. */ - tmp = fold_build2_loc (input_location, MODIFY_EXPR, type, res, - build_int_cst (type, 0)); - zero = fold_build1_loc (input_location, TRUTH_NOT_EXPR, boolean_type_node, - nonzero); - tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, zero, tmp, - build_empty_stmt (input_location)); - gfc_add_expr_to_block (block, tmp); - return res; } |