8203672: JNI exception pending in PlainSocketImpl.c
8203264: JNI exception pending in PlainDatagramSocketImpl.c:740
8203673: JNI exception pending in DualStackPlainDatagramSocketImpl.c:398
Reviewed-by: chegar, igerasim
--- a/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c Fri Nov 23 16:36:07 2018 +0900
+++ b/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c Fri Nov 23 13:16:45 2018 +0530
@@ -684,19 +684,21 @@
packetAddress = NULL;
}
}
- if (packetAddress == NULL) {
- packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port);
- /* stuff the new Inetaddress in the packet */
- (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
- } else {
- /* only get the new port number */
- port = NET_GetPortFromSockaddr(&rmtaddr);
+ if (!(*env)->ExceptionCheck(env)){
+ if (packetAddress == NULL ) {
+ packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port);
+ /* stuff the new InetAddress in the packet */
+ (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
+ } else {
+ /* only get the new port number */
+ port = NET_GetPortFromSockaddr(&rmtaddr);
+ }
+ /* and fill in the data, remote address/port and such */
+ (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
+ (jbyte *)fullPacket);
+ (*env)->SetIntField(env, packet, dp_portID, port);
+ (*env)->SetIntField(env, packet, dp_lengthID, n);
}
- /* and fill in the data, remote address/port and such */
- (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
- (jbyte *)fullPacket);
- (*env)->SetIntField(env, packet, dp_portID, port);
- (*env)->SetIntField(env, packet, dp_lengthID, n);
}
if (mallocedPacket) {
--- a/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c Fri Nov 23 16:36:07 2018 +0900
+++ b/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c Fri Nov 23 13:16:45 2018 +0530
@@ -386,15 +386,14 @@
packetAddress = NULL;
}
}
- if (packetAddress == NULL) {
- packetAddress = NET_SockaddrToInetAddress(env, &sa, &port);
- if (packetAddress != NULL) {
- /* stuff the new Inetaddress into the packet */
- (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
+ if (!(*env)->ExceptionCheck(env)){
+ if (packetAddress == NULL ) {
+ packetAddress = NET_SockaddrToInetAddress(env, &sa, &port);
+ if (packetAddress != NULL) {
+ /* stuff the new InetAddress into the packet */
+ (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
+ }
}
- }
-
- if (!(*env)->ExceptionCheck(env)) {
/* populate the packet */
(*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, rv,
(jbyte *)fullPacket);
--- a/src/java.base/windows/native/libnet/PlainSocketImpl.c Fri Nov 23 16:36:07 2018 +0900
+++ b/src/java.base/windows/native/libnet/PlainSocketImpl.c Fri Nov 23 13:16:45 2018 +0530
@@ -303,6 +303,10 @@
SetHandleInformation((HANDLE)(UINT_PTR)newfd, HANDLE_FLAG_INHERIT, 0);
ia = NET_SockaddrToInetAddress(env, &sa, &port);
+ if (ia == NULL){
+ closesocket(newfd);
+ return -1;
+ }
isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port);
if (isa == NULL) {
closesocket(newfd);