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
This commit is contained in:
Tobias Burnus 2012-05-11 10:14:56 +02:00
parent c49f925dc5
commit 5450a88f8b
2 changed files with 40 additions and 34 deletions

View file

@ -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))