8162530: src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c doesn't handle JNI exceptions properly
authordsamersoff
Mon, 22 Aug 2016 21:37:37 +0300
changeset 40689 13289e482d77
parent 40688 566173fd712c
child 40690 767d0e8ab1df
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
jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c
--- 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);