]> 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 22:33:21 +0000 (00:33 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 11 May 2012 22:33:21 +0000 (00:33 +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: r187418

libgfortran/ChangeLog
libgfortran/intrinsics/eoshift2.c

index 31e5895f4102ea7364927d519bea08e06f2b20f4..3921f72a63cfc0161063e4515e49491d18c190b8 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.
+
 2012-03-01  Release Manager
 
        * GCC 4.6.3 released.
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))