harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r996777 - /harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c
Date Tue, 14 Sep 2010 07:49:24 GMT
Author: regisxu
Date: Tue Sep 14 07:49:24 2010
New Revision: 996777

URL: http://svn.apache.org/viewvc?rev=996777&view=rev
Log:
Apply patch for HARMONY-6646: [java][classlib][luni]Potential memory corruption while freeing
the memory for NetworkInterface related functions

Modified:
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c?rev=996777&r1=996776&r2=996777&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/windows/helpers.c
Tue Sep 14 07:49:24 2010
@@ -714,6 +714,7 @@ jboolean
 getPlatformNetworkInterfaceAttribute(JNIEnv * env, FLAGTYPE type , jint jindex, DWORD flag)
 {
 	PIP_ADAPTER_ADDRESSES AdapterAddresses = NULL;
+	PIP_ADAPTER_ADDRESSES AdapterAddressesBuffer = NULL;
 	ULONG OutBufferLength = 0;
 	ULONG RetVal = 0;
 	jboolean isIPv6 = JNI_FALSE;
@@ -723,6 +724,8 @@ getPlatformNetworkInterfaceAttribute(JNI
 	PORT_ACCESS_FROM_ENV (env);
 
     AdapterAddresses = initAdapters(env, RetVal);
+	AdapterAddressesBuffer = AdapterAddresses;
+
 	isIPv6 = isIPv6Enabled (AdapterAddresses);
 	if (RetVal == NO_ERROR) {		
 		while (AdapterAddresses != NULL) {
@@ -754,8 +757,8 @@ getPlatformNetworkInterfaceAttribute(JNI
 		return 0;
 	}
 
-	if (AdapterAddresses != NULL) {
-		hymem_free_memory (AdapterAddresses);
+	if (AdapterAddressesBuffer != NULL) {
+		hymem_free_memory (AdapterAddressesBuffer);
 	}
 	return isSet;
 }
@@ -788,6 +791,7 @@ jint
 getPlatformMTU(JNIEnv * env, jstring ifname, jint index)
 {
 	PIP_ADAPTER_ADDRESSES AdapterAddresses = NULL;
+	PIP_ADAPTER_ADDRESSES AdapterAddressesBuffer = NULL;
 	ULONG OutBufferLength = 0;
 	ULONG RetVal = 0;
 	DWORD mtu = 0;
@@ -797,6 +801,8 @@ getPlatformMTU(JNIEnv * env, jstring ifn
 	PORT_ACCESS_FROM_ENV (env);
 
     AdapterAddresses = initAdapters(env, RetVal);
+	AdapterAddressesBuffer = AdapterAddresses;
+
 	isIPv6 = isIPv6Enabled (AdapterAddresses);
 
 	if (RetVal == NO_ERROR) {		
@@ -815,8 +821,8 @@ getPlatformMTU(JNIEnv * env, jstring ifn
 		return 0;
 	}
 
-	if (AdapterAddresses != NULL) {
-		hymem_free_memory (AdapterAddresses);
+	if (AdapterAddressesBuffer != NULL) {
+		hymem_free_memory (AdapterAddressesBuffer);
 	}
 	return mtu;
 }
@@ -825,6 +831,7 @@ jbyteArray 
 getPlatformHardwareAddress(JNIEnv * env, jstring ifname, jint index)
 {   
 	PIP_ADAPTER_ADDRESSES AdapterAddresses = NULL;
+	PIP_ADAPTER_ADDRESSES AdapterAddressesBuffer = NULL;
 	ULONG OutBufferLength = 0;
 	ULONG RetVal = 0; 
 	jboolean isIPv6 = JNI_FALSE;
@@ -834,6 +841,8 @@ getPlatformHardwareAddress(JNIEnv * env,
 	PORT_ACCESS_FROM_ENV (env);
 
 	AdapterAddresses = initAdapters(env, RetVal);
+	AdapterAddressesBuffer = AdapterAddresses;
+
 	isIPv6 = isIPv6Enabled(AdapterAddresses);
 
 	if (RetVal == NO_ERROR) {		
@@ -856,8 +865,8 @@ getPlatformHardwareAddress(JNIEnv * env,
 		return NULL;
 	}
 
-	if (AdapterAddresses != NULL) {
-		hymem_free_memory (AdapterAddresses);
+	if (AdapterAddressesBuffer != NULL) {
+		hymem_free_memory (AdapterAddressesBuffer);
 	}
 	return byteArray;
 }



Mime
View raw message