This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Committed,fortran] Plug memory leak.
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Dec 2016 14:11:20 -0800
- Subject: [Committed,fortran] Plug memory leak.
- Authentication-results: sourceware.org; auth=none
- Reply-to: kargl at uw dot edu
While looking at code related to PR fortran/78618, I
noticed a memory leak. The following patch plus the
leak.
2016-12-02 Steven G. Kargl <kargl@gcc.gnu.org>
* simplify.c (gfc_convert_char_constant): Free result on error.
Index: simplify.c
===================================================================
--- simplify.c (revision 243203)
+++ simplify.c (working copy)
@@ -7152,6 +7152,7 @@ gfc_convert_char_constant (gfc_expr *e,
"into character kind %d",
gfc_print_wide_char (result->value.character.string[i]),
&e->where, kind);
+ gfc_free_expr (result);
return &gfc_bad_expr;
}
Without the patch, valgrind finds
==4426== LEAK SUMMARY:
==4426== definitely lost: 192 bytes in 1 blocks
==4426== indirectly lost: 8 bytes in 1 blocks
==4426== possibly lost: 6,256 bytes in 21 blocks
==4426== still reachable: 817,676 bytes in 2,185 blocks
==4426== suppressed: 0 bytes in 0 blocks
With the patch, she shows
==15883== LEAK SUMMARY:
==15883== definitely lost: 0 bytes in 0 blocks
==15883== indirectly lost: 0 bytes in 0 blocks
==15883== possibly lost: 6,256 bytes in 21 blocks
==15883== still reachable: 817,676 bytes in 2,185 blocks
==15883== suppressed: 0 bytes in 0 blocks
--
Steve