8162530: src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c doesn't handle JNI exceptions properly

Exceptions are checked after calling NewStringUTF

Reviewed-by: dholmes, sla
This commit is contained in:
Amit Sapre 2016-08-22 21:37:37 +03:00 committed by Dmitry Samersoff
parent a5637c9afa
commit 2e533f4c60

View File

@ -87,9 +87,32 @@ JNIEXPORT void JNICALL Java_com_sun_management_internal_GcInfoBuilder_fillGcAttr
for (i = 0; i < num_attributes; i++) {
nativeTypes[i] = ext_att_info[i].type;
attName = (*env)->NewStringUTF(env, ext_att_info[i].name);
desc = (*env)->NewStringUTF(env, ext_att_info[i].description);
if ((*env)->ExceptionCheck(env)) {
free(ext_att_info);
free(nativeTypes);
return;
}
(*env)->SetObjectArrayElement(env, attributeNames, i, attName);
if ((*env)->ExceptionCheck(env)) {
free(ext_att_info);
free(nativeTypes);
return;
}
desc = (*env)->NewStringUTF(env, ext_att_info[i].description);
if ((*env)->ExceptionCheck(env)) {
free(ext_att_info);
free(nativeTypes);
return;
}
(*env)->SetObjectArrayElement(env, descriptions, i, desc);
if ((*env)->ExceptionCheck(env)) {
free(ext_att_info);
free(nativeTypes);
return;
}
}
(*env)->SetCharArrayRegion(env, types, 0, num_attributes, nativeTypes);