changeset 17563:5d5653c5bcab

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
author dsamersoff
date Mon, 22 Aug 2016 21:37:37 +0300
parents 88b20e3124c9
children fff545bf536f
files src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c
diffstat 1 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c	Sat Aug 20 09:36:35 2016 -0400
+++ b/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);
+        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);
-        (*env)->SetObjectArrayElement(env, attributeNames, i, attName);
+        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);