comparison src/share/native/sun/management/Flag.c @ 2282:83c34a6b1458

6924497: HotSpotDiagnosticsMXBean.getDiagnosticOptions throws NPE Summary: Check if the element in the flags array is non-null to filter unsupported flags Reviewed-by: dcubed
author mchung
date Mon, 08 Feb 2010 23:02:28 -0800
parents 37a05a11f281
children f8c9a5e3f5db
comparison
equal deleted inserted replaced
0:3d51d8d88a44 1:95e678e42ee9
82 { 82 {
83 char errmsg[128]; 83 char errmsg[128];
84 84
85 jint num_flags, i, index; 85 jint num_flags, i, index;
86 jmmVMGlobal* globals; 86 jmmVMGlobal* globals;
87 size_t gsize;
87 const char* class_name = "sun/management/Flag"; 88 const char* class_name = "sun/management/Flag";
88 const char* signature = "(Ljava/lang/String;Ljava/lang/Object;ZZLcom/sun/management/VMOption$Origin;)V"; 89 const char* signature = "(Ljava/lang/String;Ljava/lang/Object;ZZLcom/sun/management/VMOption$Origin;)V";
89 jobject origin; 90 jobject origin;
90 jobject valueObj; 91 jobject valueObj;
91 jobject flag; 92 jobject flag;
98 if (count == 0) { 99 if (count == 0) {
99 JNU_ThrowIllegalArgumentException(env, 0); 100 JNU_ThrowIllegalArgumentException(env, 0);
100 return 0; 101 return 0;
101 } 102 }
102 103
103 globals = (jmmVMGlobal*) malloc(count * sizeof(jmmVMGlobal)); 104 gsize = count * sizeof(jmmVMGlobal);
105 globals = (jmmVMGlobal*) malloc(gsize);
104 if (globals == NULL) { 106 if (globals == NULL) {
105 JNU_ThrowOutOfMemoryError(env, 0); 107 JNU_ThrowOutOfMemoryError(env, 0);
106 return 0; 108 return 0;
107 } 109 }
108 110
111 memset(globals, 0, gsize);
109 num_flags = jmm_interface->GetVMGlobals(env, names, globals, count); 112 num_flags = jmm_interface->GetVMGlobals(env, names, globals, count);
110 if (num_flags == 0) { 113 if (num_flags == 0) {
111 free(globals); 114 free(globals);
112 return 0; 115 return 0;
113 } 116 }