This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/53310] [4.5/4.6/4.7/4.8 Regression] EOSHIFT leaks memory
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 10 May 2012 21:27:52 +0000
- Subject: [Bug fortran/53310] [4.5/4.6/4.7/4.8 Regression] EOSHIFT leaks memory
- Auto-submitted: auto-generated
- References: <bug-53310-4@http.gcc.gnu.org/bugzilla/>
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);
-
}