Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
7095fdf5
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7095fdf5
编写于
10月 05, 2013
作者:
S
sla
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8025922: JNI access to Strings need to check if the value field is non-null
Reviewed-by: dholmes, dcubed
上级
776ca611
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
57 addition
and
41 deletion
+57
-41
src/share/vm/prims/jni.cpp
src/share/vm/prims/jni.cpp
+35
-21
src/share/vm/prims/jniCheck.cpp
src/share/vm/prims/jniCheck.cpp
+22
-20
未找到文件。
src/share/vm/prims/jni.cpp
浏览文件 @
7095fdf5
...
...
@@ -3210,7 +3210,11 @@ JNI_QUICK_ENTRY(jsize, jni_GetStringLength(JNIEnv *env, jstring string))
HOTSPOT_JNI_GETSTRINGLENGTH_ENTRY
(
env
,
string
);
#endif
/* USDT2 */
jsize
ret
=
java_lang_String
::
length
(
JNIHandles
::
resolve_non_null
(
string
));
jsize
ret
=
0
;
oop
s
=
JNIHandles
::
resolve_non_null
(
string
);
if
(
java_lang_String
::
value
(
s
)
!=
NULL
)
{
ret
=
java_lang_String
::
length
(
s
);
}
#ifndef USDT2
DTRACE_PROBE1
(
hotspot_jni
,
GetStringLength__return
,
ret
);
#else
/* USDT2 */
...
...
@@ -3230,11 +3234,13 @@ JNI_QUICK_ENTRY(const jchar*, jni_GetStringChars(
HOTSPOT_JNI_GETSTRINGCHARS_ENTRY
(
env
,
string
,
(
uintptr_t
*
)
isCopy
);
#endif
/* USDT2 */
jchar
*
buf
=
NULL
;
oop
s
=
JNIHandles
::
resolve_non_null
(
string
);
int
s_len
=
java_lang_String
::
length
(
s
);
typeArrayOop
s_value
=
java_lang_String
::
value
(
s
);
if
(
s_value
!=
NULL
)
{
int
s_len
=
java_lang_String
::
length
(
s
);
int
s_offset
=
java_lang_String
::
offset
(
s
);
jchar
*
buf
=
NEW_C_HEAP_ARRAY_RETURN_NULL
(
jchar
,
s_len
+
1
,
mtInternal
);
// add one for zero termination
buf
=
NEW_C_HEAP_ARRAY_RETURN_NULL
(
jchar
,
s_len
+
1
,
mtInternal
);
// add one for zero termination
/* JNI Specification states return NULL on OOM */
if
(
buf
!=
NULL
)
{
if
(
s_len
>
0
)
{
...
...
@@ -3246,6 +3252,7 @@ JNI_QUICK_ENTRY(const jchar*, jni_GetStringChars(
*
isCopy
=
JNI_TRUE
;
}
}
}
#ifndef USDT2
DTRACE_PROBE1
(
hotspot_jni
,
GetStringChars__return
,
buf
);
#else
/* USDT2 */
...
...
@@ -3313,7 +3320,11 @@ JNI_ENTRY(jsize, jni_GetStringUTFLength(JNIEnv *env, jstring string))
HOTSPOT_JNI_GETSTRINGUTFLENGTH_ENTRY
(
env
,
string
);
#endif
/* USDT2 */
jsize
ret
=
java_lang_String
::
utf8_length
(
JNIHandles
::
resolve_non_null
(
string
));
jsize
ret
=
0
;
oop
java_string
=
JNIHandles
::
resolve_non_null
(
string
);
if
(
java_lang_String
::
value
(
java_string
)
!=
NULL
)
{
ret
=
java_lang_String
::
utf8_length
(
java_string
);
}
#ifndef USDT2
DTRACE_PROBE1
(
hotspot_jni
,
GetStringUTFLength__return
,
ret
);
#else
/* USDT2 */
...
...
@@ -3332,16 +3343,19 @@ JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboole
HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY
(
env
,
string
,
(
uintptr_t
*
)
isCopy
);
#endif
/* USDT2 */
char
*
result
=
NULL
;
oop
java_string
=
JNIHandles
::
resolve_non_null
(
string
);
if
(
java_lang_String
::
value
(
java_string
)
!=
NULL
)
{
size_t
length
=
java_lang_String
::
utf8_length
(
java_string
);
/* JNI Specification states return NULL on OOM */
char
*
result
=
AllocateHeap
(
length
+
1
,
mtInternal
,
0
,
AllocFailStrategy
::
RETURN_NULL
);
result
=
AllocateHeap
(
length
+
1
,
mtInternal
,
0
,
AllocFailStrategy
::
RETURN_NULL
);
if
(
result
!=
NULL
)
{
java_lang_String
::
as_utf8_string
(
java_string
,
result
,
(
int
)
length
+
1
);
if
(
isCopy
!=
NULL
)
{
*
isCopy
=
JNI_TRUE
;
}
}
}
#ifndef USDT2
DTRACE_PROBE1
(
hotspot_jni
,
GetStringUTFChars__return
,
result
);
#else
/* USDT2 */
...
...
src/share/vm/prims/jniCheck.cpp
浏览文件 @
7095fdf5
...
...
@@ -1324,18 +1324,19 @@ JNI_ENTRY_CHECKED(const jchar *,
IN_VM
(
checkString
(
thr
,
str
);
)
jchar
*
newResult
=
NULL
;
const
jchar
*
result
=
UNCHECKED
()
->
GetStringChars
(
env
,
str
,
isCopy
);
assert
(
isCopy
==
NULL
||
*
isCopy
==
JNI_TRUE
,
"GetStringChars didn't return a copy as expected"
);
if
(
result
!=
NULL
)
{
size_t
len
=
UNCHECKED
()
->
GetStringLength
(
env
,
str
)
+
1
;
// + 1 for NULL termination
jint
*
tagLocation
=
(
jint
*
)
AllocateHeap
(
len
*
sizeof
(
jchar
)
+
sizeof
(
jint
),
mtInternal
);
*
tagLocation
=
STRING_TAG
;
jchar
*
newResult
=
(
jchar
*
)
(
tagLocation
+
1
);
newResult
=
(
jchar
*
)
(
tagLocation
+
1
);
memcpy
(
newResult
,
result
,
len
*
sizeof
(
jchar
));
// Avoiding call to UNCHECKED()->ReleaseStringChars() since that will fire unexpected dtrace probes
// Note that the dtrace arguments for the allocated memory will not match up with this solution.
FreeHeap
((
char
*
)
result
);
}
functionExit
(
env
);
return
newResult
;
JNI_END
...
...
@@ -1394,18 +1395,19 @@ JNI_ENTRY_CHECKED(const char *,
IN_VM
(
checkString
(
thr
,
str
);
)
char
*
newResult
=
NULL
;
const
char
*
result
=
UNCHECKED
()
->
GetStringUTFChars
(
env
,
str
,
isCopy
);
assert
(
isCopy
==
NULL
||
*
isCopy
==
JNI_TRUE
,
"GetStringUTFChars didn't return a copy as expected"
);
if
(
result
!=
NULL
)
{
size_t
len
=
strlen
(
result
)
+
1
;
// + 1 for NULL termination
jint
*
tagLocation
=
(
jint
*
)
AllocateHeap
(
len
+
sizeof
(
jint
),
mtInternal
);
*
tagLocation
=
STRING_UTF_TAG
;
char
*
newResult
=
(
char
*
)
(
tagLocation
+
1
);
newResult
=
(
char
*
)
(
tagLocation
+
1
);
strcpy
(
newResult
,
result
);
// Avoiding call to UNCHECKED()->ReleaseStringUTFChars() since that will fire unexpected dtrace probes
// Note that the dtrace arguments for the allocated memory will not match up with this solution.
FreeHeap
((
char
*
)
result
,
mtInternal
);
}
functionExit
(
env
);
return
newResult
;
JNI_END
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录