提交 806ea6b9 编写于 作者: M msheppar

8036603: Check jdk/src/windows/native/java/lang/ProcessEnvironment_md.c for JNI pending exceptions

Summary: added JNI call NULL return checks
Reviewed-by: alanb, mchung
上级 71d391a6
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2014 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -32,10 +32,17 @@ static jstring
environmentBlock9x(JNIEnv *env)
{
int i;
jmethodID String_init_ID =
(*env)->GetMethodID(env, JNU_ClassString(env), "<init>", "([B)V");
jmethodID String_init_ID;
jbyteArray bytes;
jbyte *blockA = (jbyte *) GetEnvironmentStringsA();
jbyte *blockA;
jclass string_class;
string_class= JNU_ClassString(env);
CHECK_NULL_RETURN(string_class, NULL);
String_init_ID =
(*env)->GetMethodID(env, string_class, "<init>", "([B)V");
CHECK_NULL_RETURN(String_init_ID);
blockA = (jbyte *) GetEnvironmentStringsA();
if (blockA == NULL) {
/* Both GetEnvironmentStringsW and GetEnvironmentStringsA
* failed. Out of memory is our best guess. */
......@@ -49,10 +56,13 @@ environmentBlock9x(JNIEnv *env)
while (blockA[i++])
;
if ((bytes = (*env)->NewByteArray(env, i)) == NULL) return NULL;
if ((bytes = (*env)->NewByteArray(env, i)) == NULL) {
FreeEnvironmentStringsA(blockA);
return NULL;
}
(*env)->SetByteArrayRegion(env, bytes, 0, i, blockA);
FreeEnvironmentStringsA(blockA);
return (*env)->NewObject(env, JNU_ClassString(env),
return (*env)->NewObject(env, string_class,
String_init_ID, bytes);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册