提交 d48c6319 编写于 作者: R rprotacio

8181664: Improve JVM UTF String handling

Reviewed-by: mschoene, coleenp, rhalade, acorn, gtriantafill
Contributed-by: rachel.protacio@oracle.com
上级 9873aa74
......@@ -3832,7 +3832,7 @@ jni_Get##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start,
EntryProbe; \
DT_VOID_RETURN_MARK(Get##Result##ArrayRegion); \
typeArrayOop src = typeArrayOop(JNIHandles::resolve_non_null(array)); \
if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)src->length())) { \
if (start < 0 || len < 0 || (start > src->length() - len)) { \
THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \
} else { \
if (len > 0) { \
......@@ -3916,7 +3916,7 @@ jni_Set##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start,
EntryProbe; \
DT_VOID_RETURN_MARK(Set##Result##ArrayRegion); \
typeArrayOop dst = typeArrayOop(JNIHandles::resolve_non_null(array)); \
if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)dst->length())) { \
if (start < 0 || len < 0 || (start > dst->length() - len)) { \
THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \
} else { \
if (len > 0) { \
......@@ -4200,7 +4200,7 @@ JNI_ENTRY(void, jni_GetStringRegion(JNIEnv *env, jstring string, jsize start, js
DT_VOID_RETURN_MARK(GetStringRegion);
oop s = JNIHandles::resolve_non_null(string);
int s_len = java_lang_String::length(s);
if (start < 0 || len < 0 || start + len > s_len) {
if (start < 0 || len < 0 || start > s_len - len) {
THROW(vmSymbols::java_lang_StringIndexOutOfBoundsException());
} else {
if (len > 0) {
......@@ -4229,7 +4229,7 @@ JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start,
DT_VOID_RETURN_MARK(GetStringUTFRegion);
oop s = JNIHandles::resolve_non_null(string);
int s_len = java_lang_String::length(s);
if (start < 0 || len < 0 || start + len > s_len) {
if (start < 0 || len < 0 || start > s_len - len) {
THROW(vmSymbols::java_lang_StringIndexOutOfBoundsException());
} else {
//%note jni_7
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册