diff options
author | Tobias Burnus <burnus@net-b.de> | 2012-05-11 22:33:21 +0000 |
---|---|---|
committer | Tobias Burnus <burnus@net-b.de> | 2012-05-11 22:33:21 +0000 |
commit | 513b9495524cbb47bd6ae74b1d7e56f42632c748 (patch) | |
tree | 41daf6f8f760153d6c6b05472cefe13e23f8cc1d | |
parent | b034756754282bf2fb0ae324f41c718ba18ab763 (diff) |
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: https://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@187418 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libgfortran/ChangeLog | 6 | ||||
-rw-r--r-- | libgfortran/intrinsics/eoshift2.c | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 31e5895f410..3921f72a63c 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-01 Release Manager * GCC 4.6.3 released. diff --git a/libgfortran/intrinsics/eoshift2.c b/libgfortran/intrinsics/eoshift2.c index 2fbf62e118c..fe38d058b02 100644 --- a/libgfortran/intrinsics/eoshift2.c +++ b/libgfortran/intrinsics/eoshift2.c @@ -77,6 +77,12 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array, ret->offset = 0; ret->dtype = array->dtype; + + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) { index_type ub, str; @@ -90,12 +96,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); - - if (arraysize > 0) - ret->data = internal_malloc_size (size * arraysize); - else - ret->data = internal_malloc_size (1); - } } else if (unlikely (compile_options.bounds_check)) |