Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6c7a0295
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6c7a0295
编写于
7月 25, 2008
作者:
B
bae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6687968: PNGImageReader leaks native memory through an Inflater.
Reviewed-by: igor, prr
上级
6d2b098e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
50 addition
and
23 deletion
+50
-23
src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
...e/classes/com/sun/imageio/plugins/png/PNGImageReader.java
+26
-4
src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
...e/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
+24
-19
未找到文件。
src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
浏览文件 @
6c7a0295
...
...
@@ -616,11 +616,16 @@ public class PNGImageReader extends ImageReader {
private
static
String
inflate
(
byte
[]
b
)
throws
IOException
{
InputStream
bais
=
new
ByteArrayInputStream
(
b
);
InputStream
iis
=
new
InflaterInputStream
(
bais
);
StringBuilder
sb
=
new
StringBuilder
(
80
);
int
c
;
try
{
while
((
c
=
iis
.
read
())
!=
-
1
)
{
sb
.
append
((
char
)
c
);
}
}
finally
{
iis
.
close
();
}
return
sb
.
toString
();
}
...
...
@@ -1244,13 +1249,26 @@ public class PNGImageReader extends ImageReader {
destinationBands
=
param
.
getDestinationBands
();
destinationOffset
=
param
.
getDestinationOffset
();
}
Inflater
inf
=
null
;
try
{
stream
.
seek
(
imageStartPosition
);
Enumeration
e
=
new
PNGImageDataEnumeration
(
stream
);
InputStream
is
=
new
SequenceInputStream
(
e
);
is
=
new
InflaterInputStream
(
is
,
new
Inflater
());
/* InflaterInputStream uses an Inflater instance which consumes
* native (non-GC visible) resources. This is normally implicitly
* freed when the stream is closed. However since the
* InflaterInputStream wraps a client-supplied input stream,
* we cannot close it.
* But the app may depend on GC finalization to close the stream.
* Therefore to ensure timely freeing of native resources we
* explicitly create the Inflater instance and free its resources
* when we are done with the InflaterInputStream by calling
* inf.end();
*/
inf
=
new
Inflater
();
is
=
new
InflaterInputStream
(
is
,
inf
);
is
=
new
BufferedInputStream
(
is
);
this
.
pixelStream
=
new
DataInputStream
(
is
);
...
...
@@ -1283,6 +1301,10 @@ public class PNGImageReader extends ImageReader {
}
}
catch
(
IOException
e
)
{
throw
new
IIOException
(
"Error reading PNG image data"
,
e
);
}
finally
{
if
(
inf
!=
null
)
{
inf
.
end
();
}
}
}
...
...
src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
浏览文件 @
6c7a0295
...
...
@@ -244,6 +244,7 @@ final class IDATOutputStream extends ImageOutputStreamImpl {
}
public
void
finish
()
throws
IOException
{
try
{
if
(!
def
.
finished
())
{
def
.
finish
();
while
(!
def
.
finished
())
{
...
...
@@ -251,6 +252,9 @@ final class IDATOutputStream extends ImageOutputStreamImpl {
}
}
finishChunk
();
}
finally
{
def
.
end
();
}
}
protected
void
finalize
()
throws
Throwable
{
...
...
@@ -928,7 +932,7 @@ public class PNGImageWriter extends ImageWriter {
// Use sourceXOffset, etc.
private
void
write_IDAT
(
RenderedImage
image
)
throws
IOException
{
IDATOutputStream
ios
=
new
IDATOutputStream
(
stream
,
32768
);
try
{
if
(
metadata
.
IHDR_interlaceMethod
==
1
)
{
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
encodePass
(
ios
,
image
,
...
...
@@ -943,9 +947,10 @@ public class PNGImageWriter extends ImageWriter {
}
else
{
encodePass
(
ios
,
image
,
0
,
0
,
1
,
1
);
}
}
finally
{
ios
.
finish
();
}
}
private
void
writeIEND
()
throws
IOException
{
ChunkStream
cs
=
new
ChunkStream
(
PNGImageReader
.
IEND_TYPE
,
stream
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录