src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c
Print this page
*** 55,70 ****
--- 55,78 ----
Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv *env, jclass c)
{
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 jint JNICALL
Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this,
jobject ssfdo, jobject newfdo,
*** 77,86 ****
--- 85,98 ----
jobject remote_ia = 0;
jobject isa;
jint remote_port;
NET_AllocSockaddr(&sa, &alloc_len);
+ if (sa == NULL) {
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return IOS_THROWN;
+ }
/*
* accept connection but ignore ECONNABORTED indicating that
* a connection was eagerly accepted but was reset before
* accept() was called.
*** 108,117 ****
}
(*env)->SetIntField(env, newfdo, fd_fdID, newfd);
remote_ia = NET_SockaddrToInetAddress(env, sa, (int *)&remote_port);
free((void *)sa);
! isa = (*env)->NewObject(env, isa_class, isa_ctorID,
! remote_ia, remote_port);
(*env)->SetObjectArrayElement(env, isaa, 0, isa);
return 1;
}
--- 120,130 ----
}
(*env)->SetIntField(env, newfdo, fd_fdID, newfd);
remote_ia = NET_SockaddrToInetAddress(env, sa, (int *)&remote_port);
free((void *)sa);
! CHECK_NULL_RETURN(remote_ia, IOS_THROWN);
! 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;
}