Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
P3
-
Resolution: Fixed
-
Affects Version/s: 7u51, 8, 9
-
Fix Version/s: 9
-
Component/s: client-libs
-
Subcomponent:
-
Resolved In Build:b116
-
CPU:x86
-
OS:windows_7
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8225336 | openjdk8u222 | Andrew Hughes | P3 | Resolved | Fixed | b05 |
Description
FULL PRODUCT VERSION :
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
In the ImageIO method
"write(RenderedImage im, String formatName, File output) throws IOException"
ImageOutputStream is created through code
"stream = createImageOutputStream(output);"
In the finally block stream is closed without null check
"finally { stream.close(); }"
But in the createImageOutputStream method there is a code like
"try {
iter = theRegistry.getServiceProvidersImageOutputStreamSpi.class,true);
} catch (IllegalArgumentException e) { return null; } "
so the catch block returns null which will make "stream=null" in the "write" method mentioned above.
This will throw NullPointerException in the stream.close() call.
Please put a null check in the finally block
"if(stream!= null) stream.close();"
Not just this specific write method on other write() and read() methods also we are not handling NPE properly.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
In the ImageIO method
"write(RenderedImage im, String formatName, File output) throws IOException"
ImageOutputStream is created through code
"stream = createImageOutputStream(output);"
In the finally block stream is closed without null check
"finally { stream.close(); }"
But in the createImageOutputStream method there is a code like
"try {
iter = theRegistry.getServiceProvidersImageOutputStreamSpi.class,true);
} catch (IllegalArgumentException e) { return null; } "
so the catch block returns null which will make "stream=null" in the "write" method mentioned above.
This will throw NullPointerException in the stream.close() call.
Please put a null check in the finally block
"if(stream!= null) stream.close();"
Not just this specific write method on other write() and read() methods also we are not handling NPE properly.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
Attachments
Issue Links
- backported by
-
JDK-8225336 In ImageIO.write() and ImageIO.read() null stream is not handled properly.
-
- Resolved
-