From: burnus Date: Fri, 11 May 2012 22:32:27 +0000 (+0000) Subject: 2012-05-12 Tobias Burnus X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;ds=sidebyside;h=e6fa05838e125e3e01ec6e5c3e8b8df421f4a3c1;p=pf3gnuchains%2Fgcc-fork.git 2012-05-12 Tobias Burnus 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 --- 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 + + PR fortran/53310 + * intrinsics/eoshift2.c (eoshift2): Do not leak + memory by allocating it in the loop. + 2012-03-30 Uros Bizjak 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))