[cp-patches] FYI: PR42823: TCP/IP read/write sockets cause memory leak

Dr Andrew John Hughes ahughes at redhat.com
Thu Mar 31 00:32:33 UTC 2011


I've committed the attached patch which was posted by
Gert Brettlecker on http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42823
This is short enough (two lines added) to count as a trivial
patch without copyright assignment.

ChangeLog:

2011-03-30  Gert Brettlecker  <gert.brettlecker at ergon.ch>

	PR classpath/42823
	* native/jni/java-net/java_net_VMInetAddress.c,
	(Java_VMInetAddress_getHostByAddr(JNIEnv*,jclass,jarray)):
	Free address structure after use.
	(Java_java_net_VMInetAddress_aton(JNIEnv*,jclass,jstring)):
	Release UTF string after use.

-- 
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and IcedTea
http://www.gnu.org/software/classpath
http://icedtea.classpath.org
PGP Key: F5862A37 (https://keys.indymedia.org/)
Fingerprint = EA30 D855 D50F 90CD F54D  0698 0713 C3ED F586 2A37
-------------- next part --------------
Index: native/jni/java-net/java_net_VMInetAddress.c
===================================================================
RCS file: /sources/classpath/classpath/native/jni/java-net/java_net_VMInetAddress.c,v
retrieving revision 1.11
diff -u -u -r1.11 java_net_VMInetAddress.c
--- native/jni/java-net/java_net_VMInetAddress.c	11 Jan 2008 22:14:31 -0000	1.11
+++ native/jni/java-net/java_net_VMInetAddress.c	30 Mar 2011 23:14:13 -0000
@@ -180,6 +180,7 @@
 
   /* Resolve the address and return the name */
   result = cpnet_getHostByAddr (env, addr, hostname, sizeof (hostname));
+  cpnet_freeAddress (env, addr);
   if (result != CPNATIVE_OK)
     {
       JCL_ThrowException (env, UNKNOWN_HOST_EXCEPTION,
@@ -330,6 +331,7 @@
     }
 
   result = cpnet_aton (env, hostname, &address);
+  (*env)->ReleaseStringUTFChars (env, host, hostname);
   if (result != CPNATIVE_OK)
     {
       JCL_ThrowException (env, UNKNOWN_HOST_EXCEPTION, "Internal Error");


More information about the Classpath-patches mailing list