Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f1409fc8
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f1409fc8
编写于
6月 18, 2010
作者:
B
bae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6925710: IndexColorModel.finalize can be made to double free
Reviewed-by: igor, prr, hawtin
上级
a1cedac9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
36 deletion
+67
-36
src/share/classes/java/awt/image/IndexColorModel.java
src/share/classes/java/awt/image/IndexColorModel.java
+2
-1
src/share/classes/sun/awt/image/BufImgSurfaceData.java
src/share/classes/sun/awt/image/BufImgSurfaceData.java
+18
-3
src/share/native/sun/awt/image/BufImgSurfaceData.c
src/share/native/sun/awt/image/BufImgSurfaceData.c
+47
-32
未找到文件。
src/share/classes/java/awt/image/IndexColorModel.java
浏览文件 @
f1409fc8
...
@@ -129,6 +129,8 @@ public class IndexColorModel extends ColorModel {
...
@@ -129,6 +129,8 @@ public class IndexColorModel extends ColorModel {
private
boolean
allgrayopaque
;
private
boolean
allgrayopaque
;
private
BigInteger
validBits
;
private
BigInteger
validBits
;
private
sun
.
awt
.
image
.
BufImgSurfaceData
.
ICMColorData
colorData
=
null
;
private
static
int
[]
opaqueBits
=
{
8
,
8
,
8
};
private
static
int
[]
opaqueBits
=
{
8
,
8
,
8
};
private
static
int
[]
alphaBits
=
{
8
,
8
,
8
,
8
};
private
static
int
[]
alphaBits
=
{
8
,
8
,
8
,
8
};
...
@@ -1511,7 +1513,6 @@ public class IndexColorModel extends ColorModel {
...
@@ -1511,7 +1513,6 @@ public class IndexColorModel extends ColorModel {
* longer referenced.
* longer referenced.
*/
*/
public
void
finalize
()
{
public
void
finalize
()
{
sun
.
awt
.
image
.
BufImgSurfaceData
.
freeNativeICMData
(
this
);
}
}
/**
/**
...
...
src/share/classes/sun/awt/image/BufImgSurfaceData.java
浏览文件 @
f1409fc8
...
@@ -49,7 +49,7 @@ public class BufImgSurfaceData extends SurfaceData {
...
@@ -49,7 +49,7 @@ public class BufImgSurfaceData extends SurfaceData {
private
BufferedImageGraphicsConfig
graphicsConfig
;
private
BufferedImageGraphicsConfig
graphicsConfig
;
RenderLoops
solidloops
;
RenderLoops
solidloops
;
private
static
native
void
initIDs
(
Class
ICM
);
private
static
native
void
initIDs
(
Class
ICM
,
Class
ICMColorData
);
private
static
final
int
DCM_RGBX_RED_MASK
=
0xff000000
;
private
static
final
int
DCM_RGBX_RED_MASK
=
0xff000000
;
private
static
final
int
DCM_RGBX_GREEN_MASK
=
0x00ff0000
;
private
static
final
int
DCM_RGBX_GREEN_MASK
=
0x00ff0000
;
...
@@ -67,7 +67,7 @@ public class BufImgSurfaceData extends SurfaceData {
...
@@ -67,7 +67,7 @@ public class BufImgSurfaceData extends SurfaceData {
private
static
final
int
DCM_ARGBBM_BLUE_MASK
=
0x000000ff
;
private
static
final
int
DCM_ARGBBM_BLUE_MASK
=
0x000000ff
;
static
{
static
{
initIDs
(
IndexColorModel
.
class
);
initIDs
(
IndexColorModel
.
class
,
ICMColorData
.
class
);
}
}
public
static
SurfaceData
createData
(
BufferedImage
bufImg
)
{
public
static
SurfaceData
createData
(
BufferedImage
bufImg
)
{
...
@@ -403,7 +403,7 @@ public class BufImgSurfaceData extends SurfaceData {
...
@@ -403,7 +403,7 @@ public class BufImgSurfaceData extends SurfaceData {
// their pixels are immediately retrievable anyway.
// their pixels are immediately retrievable anyway.
}
}
p
ublic
static
native
void
freeNativeICMData
(
IndexColorModel
icm
);
p
rivate
static
native
void
freeNativeICMData
(
long
pData
);
/**
/**
* Returns destination Image associated with this SurfaceData.
* Returns destination Image associated with this SurfaceData.
...
@@ -411,4 +411,19 @@ public class BufImgSurfaceData extends SurfaceData {
...
@@ -411,4 +411,19 @@ public class BufImgSurfaceData extends SurfaceData {
public
Object
getDestination
()
{
public
Object
getDestination
()
{
return
bufImg
;
return
bufImg
;
}
}
public
static
final
class
ICMColorData
{
private
long
pData
=
0L
;
private
ICMColorData
(
long
pData
)
{
this
.
pData
=
pData
;
}
public
void
finalize
()
{
if
(
pData
!=
0L
)
{
BufImgSurfaceData
.
freeNativeICMData
(
pData
);
pData
=
0L
;
}
}
}
}
}
src/share/native/sun/awt/image/BufImgSurfaceData.c
浏览文件 @
f1409fc8
...
@@ -48,9 +48,12 @@ static ColorData *BufImg_SetupICM(JNIEnv *env, BufImgSDOps *bisdo);
...
@@ -48,9 +48,12 @@ static ColorData *BufImg_SetupICM(JNIEnv *env, BufImgSDOps *bisdo);
static
jfieldID
rgbID
;
static
jfieldID
rgbID
;
static
jfieldID
mapSizeID
;
static
jfieldID
mapSizeID
;
static
jfieldID
CMpDataID
;
static
jfieldID
colorDataID
;
static
jfieldID
pDataID
;
static
jfieldID
allGrayID
;
static
jfieldID
allGrayID
;
static
jclass
clsICMCD
;
static
jmethodID
initICMCDmID
;
/*
/*
* Class: sun_awt_image_BufImgSurfaceData
* Class: sun_awt_image_BufImgSurfaceData
* Method: initIDs
* Method: initIDs
...
@@ -58,18 +61,23 @@ static jfieldID allGrayID;
...
@@ -58,18 +61,23 @@ static jfieldID allGrayID;
*/
*/
JNIEXPORT
void
JNICALL
JNIEXPORT
void
JNICALL
Java_sun_awt_image_BufImgSurfaceData_initIDs
Java_sun_awt_image_BufImgSurfaceData_initIDs
(
JNIEnv
*
env
,
jclass
bisd
,
jclass
icm
)
(
JNIEnv
*
env
,
jclass
bisd
,
jclass
icm
,
jclass
cd
)
{
{
if
(
sizeof
(
BufImgRIPrivate
)
>
SD_RASINFO_PRIVATE_SIZE
)
{
if
(
sizeof
(
BufImgRIPrivate
)
>
SD_RASINFO_PRIVATE_SIZE
)
{
JNU_ThrowInternalError
(
env
,
"Private RasInfo structure too large!"
);
JNU_ThrowInternalError
(
env
,
"Private RasInfo structure too large!"
);
return
;
return
;
}
}
clsICMCD
=
(
*
env
)
->
NewWeakGlobalRef
(
env
,
cd
);
initICMCDmID
=
(
*
env
)
->
GetMethodID
(
env
,
cd
,
"<init>"
,
"(J)V"
);
pDataID
=
(
*
env
)
->
GetFieldID
(
env
,
cd
,
"pData"
,
"J"
);
rgbID
=
(
*
env
)
->
GetFieldID
(
env
,
icm
,
"rgb"
,
"[I"
);
rgbID
=
(
*
env
)
->
GetFieldID
(
env
,
icm
,
"rgb"
,
"[I"
);
allGrayID
=
(
*
env
)
->
GetFieldID
(
env
,
icm
,
"allgrayopaque"
,
"Z"
);
allGrayID
=
(
*
env
)
->
GetFieldID
(
env
,
icm
,
"allgrayopaque"
,
"Z"
);
mapSizeID
=
(
*
env
)
->
GetFieldID
(
env
,
icm
,
"map_size"
,
"I"
);
mapSizeID
=
(
*
env
)
->
GetFieldID
(
env
,
icm
,
"map_size"
,
"I"
);
CMpDataID
=
(
*
env
)
->
GetFieldID
(
env
,
icm
,
"pData"
,
"J"
);
colorDataID
=
(
*
env
)
->
GetFieldID
(
env
,
icm
,
"colorData"
,
if
(
allGrayID
==
0
||
rgbID
==
0
||
mapSizeID
==
0
||
CMpDataID
==
0
)
{
"Lsun/awt/image/BufImgSurfaceData$ICMColorData;"
);
if
(
allGrayID
==
0
||
rgbID
==
0
||
mapSizeID
==
0
||
pDataID
==
0
||
colorDataID
==
0
||
initICMCDmID
==
0
)
{
JNU_ThrowInternalError
(
env
,
"Could not get field IDs"
);
JNU_ThrowInternalError
(
env
,
"Could not get field IDs"
);
}
}
}
}
...
@@ -81,18 +89,9 @@ Java_sun_awt_image_BufImgSurfaceData_initIDs
...
@@ -81,18 +89,9 @@ Java_sun_awt_image_BufImgSurfaceData_initIDs
*/
*/
JNIEXPORT
void
JNICALL
JNIEXPORT
void
JNICALL
Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData
Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData
(
JNIEnv
*
env
,
jclass
sd
,
j
object
icm
)
(
JNIEnv
*
env
,
jclass
sd
,
j
long
pData
)
{
{
jlong
pData
;
ColorData
*
cdata
=
(
ColorData
*
)
jlong_to_ptr
(
pData
);
ColorData
*
cdata
;
if
(
JNU_IsNull
(
env
,
icm
))
{
JNU_ThrowNullPointerException
(
env
,
"IndexColorModel cannot be null"
);
return
;
}
pData
=
(
*
env
)
->
GetLongField
(
env
,
icm
,
CMpDataID
);
cdata
=
(
ColorData
*
)
pData
;
freeICMColorData
(
cdata
);
freeICMColorData
(
cdata
);
}
}
...
@@ -259,32 +258,48 @@ static void BufImg_Release(JNIEnv *env,
...
@@ -259,32 +258,48 @@ static void BufImg_Release(JNIEnv *env,
static
ColorData
*
BufImg_SetupICM
(
JNIEnv
*
env
,
static
ColorData
*
BufImg_SetupICM
(
JNIEnv
*
env
,
BufImgSDOps
*
bisdo
)
BufImgSDOps
*
bisdo
)
{
{
ColorData
*
cData
;
ColorData
*
cData
=
NULL
;
jobject
colorData
;
if
(
JNU_IsNull
(
env
,
bisdo
->
icm
))
{
if
(
JNU_IsNull
(
env
,
bisdo
->
icm
))
{
return
(
ColorData
*
)
NULL
;
return
(
ColorData
*
)
NULL
;
}
}
c
Data
=
(
ColorData
*
)
JNU_GetLongFieldAsPtr
(
env
,
bisdo
->
icm
,
CMp
DataID
);
c
olorData
=
(
*
env
)
->
GetObjectField
(
env
,
bisdo
->
icm
,
color
DataID
);
if
(
cData
==
NULL
)
{
if
(
JNU_IsNull
(
env
,
colorData
))
{
cData
=
(
ColorData
*
)
calloc
(
1
,
sizeof
(
ColorData
));
if
(
JNU_IsNull
(
env
,
clsICMCD
))
{
// we are unable to create a wrapper object
return
(
ColorData
*
)
NULL
;
}
}
else
{
cData
=
(
ColorData
*
)
JNU_GetLongFieldAsPtr
(
env
,
colorData
,
pDataID
);
}
if
(
cData
!=
NULL
)
{
return
cData
;
}
cData
=
(
ColorData
*
)
calloc
(
1
,
sizeof
(
ColorData
));
if
(
cData
!=
NULL
)
{
if
(
cData
!=
NULL
)
{
jboolean
allGray
jboolean
allGray
=
(
*
env
)
->
GetBooleanField
(
env
,
bisdo
->
icm
,
allGrayID
);
=
(
*
env
)
->
GetBooleanField
(
env
,
bisdo
->
icm
,
allGrayID
);
int
*
pRgb
=
(
int
*
)
int
*
pRgb
=
(
int
*
)
((
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
bisdo
->
lutarray
,
NULL
));
((
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
bisdo
->
lutarray
,
NULL
));
cData
->
img_clr_tbl
=
initCubemap
(
pRgb
,
bisdo
->
lutsize
,
32
);
cData
->
img_clr_tbl
=
initCubemap
(
pRgb
,
bisdo
->
lutsize
,
32
);
if
(
allGray
==
JNI_TRUE
)
{
if
(
allGray
==
JNI_TRUE
)
{
initInverseGrayLut
(
pRgb
,
bisdo
->
lutsize
,
cData
);
initInverseGrayLut
(
pRgb
,
bisdo
->
lutsize
,
cData
);
}
}
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
bisdo
->
lutarray
,
pRgb
,
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
bisdo
->
lutarray
,
pRgb
,
JNI_ABORT
);
JNI_ABORT
);
initDitherTables
(
cData
);
initDitherTables
(
cData
);
JNU_SetLongFieldFromPtr
(
env
,
bisdo
->
icm
,
CMpDataID
,
cData
);
if
(
JNU_IsNull
(
env
,
colorData
))
{
jlong
pData
=
ptr_to_jlong
(
cData
);
colorData
=
(
*
env
)
->
NewObjectA
(
env
,
clsICMCD
,
initICMCDmID
,
(
jvalue
*
)
&
pData
);
(
*
env
)
->
SetObjectField
(
env
,
bisdo
->
icm
,
colorDataID
,
colorData
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录