8162530: src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c doesn't handle JNI exceptions properly
Summary: Exceptions are checked after calling NewStringUTF
Reviewed-by: dholmes, sla
Contributed-by: amit.sapre@oracle.com
--- a/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c Sat Aug 20 09:36:35 2016 -0400
+++ b/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c Mon Aug 22 21:37:37 2016 +0300
@@ -87,9 +87,32 @@
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);