提交 0c67d762 编写于 作者: K khazra

8020498: Crash when both libnet.so and libmawt.so are loaded

Reviewed-by: chegar, dsamersoff
上级 9b58b71a
......@@ -75,7 +75,7 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
static int initialized = 0;
void init(JNIEnv *env) {
static void initInetAddrs(JNIEnv *env) {
if (!initialized) {
Java_java_net_InetAddress_init(env, 0);
Java_java_net_Inet4Address_init(env, 0);
......@@ -96,42 +96,43 @@ extern jfieldID iac_familyID;
void setInetAddress_addr(JNIEnv *env, jobject iaObj, int address) {
jobject holder;
init(env);
initInetAddrs(env);
holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
(*env)->SetIntField(env, holder, iac_addressID, address);
}
void setInetAddress_family(JNIEnv *env, jobject iaObj, int family) {
jobject holder;
init(env);
initInetAddrs(env);
holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
(*env)->SetIntField(env, holder, iac_familyID, family);
}
void setInetAddress_hostName(JNIEnv *env, jobject iaObj, jobject host) {
jobject holder;
init(env);
initInetAddrs(env);
holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
(*env)->SetObjectField(env, holder, iac_hostNameID, host);
}
int getInetAddress_addr(JNIEnv *env, jobject iaObj) {
jobject holder;
init(env);
initInetAddrs(env);
holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
return (*env)->GetIntField(env, holder, iac_addressID);
}
int getInetAddress_family(JNIEnv *env, jobject iaObj) {
jobject holder;
init(env);
initInetAddrs(env);
holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
return (*env)->GetIntField(env, holder, iac_familyID);
}
jobject getInetAddress_hostName(JNIEnv *env, jobject iaObj) {
jobject holder;
init(env);
initInetAddrs(env);
holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
return (*env)->GetObjectField(env, holder, iac_hostNameID);
}
......@@ -139,7 +140,7 @@ jobject getInetAddress_hostName(JNIEnv *env, jobject iaObj) {
JNIEXPORT jobject JNICALL
NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
jobject iaObj;
init(env);
initInetAddrs(env);
#ifdef AF_INET6
if (him->sa_family == AF_INET6) {
jbyteArray ipaddress;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册