8036607: JNI exception pending in jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c
authormsheppar
Fri, 21 Mar 2014 00:13:40 +0000
changeset 23564 62146f638e22
parent 23563 71ed058849d4
child 23565 b28f771b8cbe
8036607: JNI exception pending in jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c Summary: check for JNI pending exception and NULL returns from JNI calls in DualStackPlainDatagramSocketImpl.c Reviewed-by: alanb
jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c
--- a/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c	Fri Mar 21 00:01:59 2014 +0000
+++ b/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c	Fri Mar 21 00:13:40 2014 +0000
@@ -384,15 +384,19 @@
         if (packetAddress == NULL) {
             packetAddress = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa,
                                                       &port);
-            /* stuff the new Inetaddress into the packet */
-            (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
+            if (packetAddress != NULL) {
+                /* stuff the new Inetaddress into the packet */
+                (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
+            }
         }
 
-        /* populate the packet */
-        (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, rv,
+        if (!(*env)->ExceptionCheck(env)) {
+            /* populate the packet */
+            (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, rv,
                                    (jbyte *)fullPacket);
-        (*env)->SetIntField(env, dpObj, dp_portID, port);
-        (*env)->SetIntField(env, dpObj, dp_lengthID, rv);
+            (*env)->SetIntField(env, dpObj, dp_portID, port);
+            (*env)->SetIntField(env, dpObj, dp_lengthID, rv);
+        }
     }
 
     if (packetBufferLen > MAX_BUFFER_LEN) {