]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/53310 (EOSHIFT leaks memory)
authorTobias Burnus <burnus@net-b.de>
Fri, 11 May 2012 23:09:30 +0000 (01:09 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 11 May 2012 23:09:30 +0000 (01:09 +0200)
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.

From-SVN: r187419

libgfortran/ChangeLog
libgfortran/intrinsics/eoshift2.c

index 4db2645500c9e4108ec165c1cf7dbef0808ef25d..8b2e8e777f0943f29e48cfe2dd3bb42d3b439ff2 100644 (file)
@@ -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.
+
 2011-08-30  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from trunk
index 2fbf62e118c70675e7b6b83df54738a80efc1c63..fe38d058b029eb7e59e9ee9cb3142df2ce0457d3 100644 (file)
@@ -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))