summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-11 22:32:27 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-11 22:32:27 +0000
commite6fa05838e125e3e01ec6e5c3e8b8df421f4a3c1 (patch)
tree2218995fc6fa31acc576aa289ee44736728dccdd
parentc2f3703e8bc025f0e7314d5fb5fd6778d313865e (diff)
downloadgcc-e6fa05838e125e3e01ec6e5c3e8b8df421f4a3c1.tar.gz
2012-05-12 Tobias Burnus <burnus@net-b.de>
PR fortran/53310 * intrinsics/eoshift2.c (eoshift2): Do not leak memory by allocating it in the loop. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@187417 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/intrinsics/eoshift2.c8
2 files changed, 10 insertions, 4 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 2c13d6b3e5d..1db2c6014cc 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-12 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/53310
+ * intrinsics/eoshift2.c (eoshift2): Do not leak
+ memory by allocating it in the loop.
+
2012-03-30 Uros Bizjak <ubizjak@gmail.com>
PR libgfortran/52758
diff --git a/libgfortran/intrinsics/eoshift2.c b/libgfortran/intrinsics/eoshift2.c
index b4f82786964..c1b326b0e44 100644
--- a/libgfortran/intrinsics/eoshift2.c
+++ b/libgfortran/intrinsics/eoshift2.c
@@ -77,6 +77,10 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
ret->offset = 0;
ret->dtype = array->dtype;
+
+ /* internal_malloc_size allocates a single byte for zero size. */
+ ret->data = internal_malloc_size (size * arraysize);
+
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
{
index_type ub, str;
@@ -90,10 +94,6 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
* GFC_DESCRIPTOR_STRIDE(ret,i-1);
GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
-
- /* internal_malloc_size allocates a single byte for zero size. */
- ret->data = internal_malloc_size (size * arraysize);
-
}
}
else if (unlikely (compile_options.bounds_check))