src/windows/native/sun/nio/ch/ServerSocketChannelImpl.c
Print this page
@@ -54,16 +54,24 @@
JNIEXPORT void JNICALL
Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv *env, jclass cls)
{
cls = (*env)->FindClass(env, "java/io/FileDescriptor");
+ CHECK_NULL(cls);
fd_fdID = (*env)->GetFieldID(env, cls, "fd", "I");
+ CHECK_NULL(fd_fdID);
cls = (*env)->FindClass(env, "java/net/InetSocketAddress");
+ CHECK_NULL(cls);
isa_class = (*env)->NewGlobalRef(env, cls);
+ if (isa_class == NULL) {
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return;
+ }
isa_ctorID = (*env)->GetMethodID(env, cls, "<init>",
"(Ljava/net/InetAddress;I)V");
+ CHECK_NULL(isa_ctorID);
}
JNIEXPORT void JNICALL
Java_sun_nio_ch_ServerSocketChannelImpl_listen(JNIEnv *env, jclass cl,
jobject fdo, jint backlog)
@@ -97,12 +105,12 @@
return IOS_THROWN;
}
(*env)->SetIntField(env, newfdo, fd_fdID, newfd);
remote_ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, (int *)&remote_port);
+ CHECK_NULL_RETURN(remote_ia, IOS_THROWN);
- isa = (*env)->NewObject(env, isa_class, isa_ctorID,
- remote_ia, remote_port);
+ isa = (*env)->NewObject(env, isa_class, isa_ctorID, remote_ia, remote_port);
+ CHECK_NULL_RETURN(isa, IOS_THROWN);
(*env)->SetObjectArrayElement(env, isaa, 0, isa);
-
return 1;
}