This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: possible memory leak
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 1 Jul 2003 16:18:57 +0200
- Subject: Patch: possible memory leak
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I know this leak is academic/insignificant but I wanted to start
things like this and I found it while playing with valgrind.
The attached patch fixes a 40 byte (at least here) memleak while
initializing the converter stuff. This leak can only occur once
during initializiation.
Okay to commit to trunk ?
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE/AZhbWSOgCCdjSDsRAiILAJ9SLivBPqL7WZTZlLg5dx9KPLMjkQCgjtYR
sZUDu5vVaWOJrvYiKHHbxtk=
=2Aiu
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2012
diff -u -b -B -r1.2012 ChangeLog
--- ChangeLog 30 Jun 2003 23:53:27 -0000 1.2012
+++ ChangeLog 1 Jul 2003 14:08:41 -0000
@@ -1,3 +1,9 @@
+2003-07-01 Michael Koch <konqueror@gmx.de>
+
+ * gnu/gcj/convert/natIconv.cc
+ (iconv_init): Fixed possible memory leak by releasing allocated iconv
+ handle.
+
2003-06-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* glib-2.0.m4: New file.
Index: gnu/gcj/convert/natIconv.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/convert/natIconv.cc,v
retrieving revision 1.13
diff -u -b -B -r1.13 natIconv.cc
--- gnu/gcj/convert/natIconv.cc 18 Feb 2002 02:52:44 -0000 1.13
+++ gnu/gcj/convert/natIconv.cc 1 Jul 2003 14:08:41 -0000
@@ -268,6 +268,9 @@
// Conversion must be complete for us to use the result.
if (r != (size_t) -1 && inc == 0 && outc == 0)
result = (c != 0xfeff);
+
+ // Release iconv handle.
+ iconv_close (handle);
}
#endif /* HAVE_ICONV */
return result;