Mercurial > hg > shenandoah-preopenjdk-archive > openjdk8 > jdk
changeset 9362:343f4f8ba098 jdk8u5-b02
8029735: Enhance service mgmt natives
Reviewed-by: sla, mschoene
author | jbachorik |
---|---|
date | Mon, 23 Dec 2013 15:33:11 +0100 |
parents | 3548e3337c02 |
children | 4ce1456131fb |
files | src/share/native/sun/management/Flag.c src/share/native/sun/management/GcInfoBuilder.c |
diffstat | 2 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/native/sun/management/Flag.c Mon Dec 23 14:29:27 2013 +0100 +++ b/src/share/native/sun/management/Flag.c Mon Dec 23 15:33:11 2013 +0100 @@ -95,12 +95,12 @@ return 0; } - if (count == 0) { + if (count <= 0) { JNU_ThrowIllegalArgumentException(env, 0); return 0; } - gsize = count * sizeof(jmmVMGlobal); + gsize = (size_t)count * sizeof(jmmVMGlobal); globals = (jmmVMGlobal*) malloc(gsize); if (globals == NULL) { JNU_ThrowOutOfMemoryError(env, 0);
--- a/src/share/native/sun/management/GcInfoBuilder.c Mon Dec 23 14:29:27 2013 +0100 +++ b/src/share/native/sun/management/GcInfoBuilder.c Mon Dec 23 15:33:11 2013 +0100 @@ -59,12 +59,12 @@ return; } - if (num_attributes == 0) { + if (num_attributes <= 0) { JNU_ThrowIllegalArgumentException(env, "Invalid num_attributes"); return; } - ext_att_info = (jmmExtAttributeInfo*) malloc(num_attributes * + ext_att_info = (jmmExtAttributeInfo*) malloc((size_t)num_attributes * sizeof(jmmExtAttributeInfo)); if (ext_att_info == NULL) { JNU_ThrowOutOfMemoryError(env, 0); @@ -78,7 +78,7 @@ return; } - nativeTypes = (jchar*) malloc(num_attributes * sizeof(jchar)); + nativeTypes = (jchar*) malloc((size_t)num_attributes * sizeof(jchar)); if (nativeTypes == NULL) { free(ext_att_info); JNU_ThrowOutOfMemoryError(env, 0); @@ -188,11 +188,16 @@ return 0; } + if (ext_att_count <= 0) { + JNU_ThrowIllegalArgumentException(env, "Invalid ext_att_count"); + return; + } + gc_stat.usage_before_gc = usageBeforeGC; gc_stat.usage_after_gc = usageAfterGC; gc_stat.gc_ext_attribute_values_size = ext_att_count; if (ext_att_count > 0) { - gc_stat.gc_ext_attribute_values = (jvalue*) malloc(ext_att_count * + gc_stat.gc_ext_attribute_values = (jvalue*) malloc((size_t)ext_att_count * sizeof(jvalue)); if (gc_stat.gc_ext_attribute_values == NULL) { JNU_ThrowOutOfMemoryError(env, 0); @@ -212,7 +217,7 @@ } // convert the ext_att_types to native types - nativeTypes = (jchar*) malloc(ext_att_count * sizeof(jchar)); + nativeTypes = (jchar*) malloc((size_t)ext_att_count * sizeof(jchar)); if (nativeTypes == NULL) { if (gc_stat.gc_ext_attribute_values != NULL) { free(gc_stat.gc_ext_attribute_values);