This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/53310] [4.5/4.6/4.7/4.8 Regression] EOSHIFT leaks memory


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53310

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org
   Target Milestone|---                         |4.6.4

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-10 21:27:52 UTC ---
Draft patch. I think it makes sense to move the allocation out of the loop:


--- a/libgfortran/intrinsics/eoshift2.c
+++ b/libgfortran/intrinsics/eoshift2.c
@@ -79,2 +79,6 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
       ret->dtype = array->dtype;
+
+      /* xmalloc allocates a single byte for zero size.  */
+      ret->base_addr = xmalloc (size * arraysize);
+
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
@@ -92,6 +96,2 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
          GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
-
-          /* xmalloc allocates a single byte for zero size.  */
-         ret->base_addr = xmalloc (size * arraysize);
-
         }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]