aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics
diff options
context:
space:
mode:
authorTobias Burnus <burnus@gcc.gnu.org>2012-05-11 10:14:56 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2012-05-11 10:14:56 +0200
commit5450a88f8ba4e2e561330b5ed45ffff008f2f730 (patch)
tree23915ca900d79e44e436266b0860c9c6b1c480b8 /libgfortran/intrinsics
parentc49f925dc5b365e529d0d879b73b8bc1754cda4b (diff)
downloadgcc-5450a88f8ba4e2e561330b5ed45ffff008f2f730.zip
gcc-5450a88f8ba4e2e561330b5ed45ffff008f2f730.tar.gz
gcc-5450a88f8ba4e2e561330b5ed45ffff008f2f730.tar.bz2
re PR fortran/53310 (EOSHIFT leaks memory)
2012-05-11 Tobias Burnus <burnus@net-b.de> PR fortran/53310 * intrinsics/eoshift2.c (eoshift2): Do not leak memory by allocating it in the loop. From-SVN: r187395
Diffstat (limited to 'libgfortran/intrinsics')
-rw-r--r--libgfortran/intrinsics/eoshift2.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libgfortran/intrinsics/eoshift2.c b/libgfortran/intrinsics/eoshift2.c
index d0d0bf1..ff94176 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;
+
+ /* xmalloc allocates a single byte for zero size. */
+ ret->base_addr = xmalloc (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);
-
- /* xmalloc allocates a single byte for zero size. */
- ret->base_addr = xmalloc (size * arraysize);
-
}
}
else if (unlikely (compile_options.bounds_check))