OSDN Git Service

2012-05-12 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 May 2012 22:32:27 +0000 (22:32 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 May 2012 22:32:27 +0000 (22:32 +0000)
        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

libgfortran/ChangeLog
libgfortran/intrinsics/eoshift2.c

index 2c13d6b..1db2c60 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-30  Uros Bizjak  <ubizjak@gmail.com>
 
        PR libgfortran/52758
 2012-03-30  Uros Bizjak  <ubizjak@gmail.com>
 
        PR libgfortran/52758
index b4f8278..c1b326b 100644 (file)
@@ -77,6 +77,10 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
 
       ret->offset = 0;
       ret->dtype = array->dtype;
 
       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;
       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);
              * 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))
         }
     }
   else if (unlikely (compile_options.bounds_check))