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
This commit is contained in:
Vyom Tewari 2018-11-23 13:16:45 +05:30
parent 4663065fad
commit 19e69dc84f
3 changed files with 25 additions and 20 deletions

View file

@ -684,19 +684,21 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this,
packetAddress = NULL; packetAddress = NULL;
} }
} }
if (packetAddress == NULL) { if (!(*env)->ExceptionCheck(env)){
packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port); if (packetAddress == NULL ) {
/* stuff the new Inetaddress in the packet */ packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port);
(*env)->SetObjectField(env, packet, dp_addressID, packetAddress); /* stuff the new InetAddress in the packet */
} else { (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
/* only get the new port number */ } else {
port = NET_GetPortFromSockaddr(&rmtaddr); /* 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) { if (mallocedPacket) {

View file

@ -386,15 +386,14 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketRece
packetAddress = NULL; packetAddress = NULL;
} }
} }
if (packetAddress == NULL) { if (!(*env)->ExceptionCheck(env)){
packetAddress = NET_SockaddrToInetAddress(env, &sa, &port); if (packetAddress == NULL ) {
if (packetAddress != NULL) { packetAddress = NET_SockaddrToInetAddress(env, &sa, &port);
/* stuff the new Inetaddress into the packet */ if (packetAddress != NULL) {
(*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress); /* stuff the new InetAddress into the packet */
(*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
}
} }
}
if (!(*env)->ExceptionCheck(env)) {
/* populate the packet */ /* populate the packet */
(*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, rv, (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, rv,
(jbyte *)fullPacket); (jbyte *)fullPacket);

View file

@ -303,6 +303,10 @@ JNIEXPORT jint JNICALL Java_java_net_PlainSocketImpl_accept0
SetHandleInformation((HANDLE)(UINT_PTR)newfd, HANDLE_FLAG_INHERIT, 0); SetHandleInformation((HANDLE)(UINT_PTR)newfd, HANDLE_FLAG_INHERIT, 0);
ia = NET_SockaddrToInetAddress(env, &sa, &port); ia = NET_SockaddrToInetAddress(env, &sa, &port);
if (ia == NULL){
closesocket(newfd);
return -1;
}
isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port); isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port);
if (isa == NULL) { if (isa == NULL) {
closesocket(newfd); closesocket(newfd);