]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/53521 (Memory leak with zero-sized array constructor)
authorTobias Burnus <burnus@net-b.de>
Fri, 1 Jun 2012 20:06:39 +0000 (22:06 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 1 Jun 2012 20:06:39 +0000 (22:06 +0200)
2012-06-01  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53521
        * trans.c (gfc_deallocate_scalar_with_status): Properly
        handle the case size == 0.

From-SVN: r188124

gcc/fortran/ChangeLog
gcc/fortran/trans.c

index e9d912eb6cf89172a8410d52aec822eb73851de7..c5654f63b69e0a2feea462379bdb414eaf4f1275 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-01  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/53521
+       * trans.c (gfc_deallocate_scalar_with_status): Properly
+       handle the case size == 0.
+
 2012-05-23  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/53389
index 27a352ab3bd4f0a524c2abc6220ea6b55f11f811..0dc8240983398d2d317ce0bb54db286575841ae2 100644 (file)
@@ -1005,15 +1005,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);
@@ -1044,15 +1041,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;
 }