[ 
https://issues.apache.org/jira/browse/PDFBOX-4665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16947023#comment-16947023
 ] 

ASF subversion and git services commented on PDFBOX-4665:
---------------------------------------------------------

Commit 1868149 from Tilman Hausherr in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1868149 ]

PDFBOX-4665: close file on exception, as suggested by Chris Cockayne

> PDImageXObject createFromFileByExtension does not close FileInputStream in 
> event of error
> -----------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-4665
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4665
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.17
>            Reporter: Chris Cockayne
>            Priority: Minor
>             Fix For: 3.0.0 PDFBox
>
>
> if you pass a mislabelled jpeg image file to 
> PDImageXObject.createFromFileByExtension, e.g. a png image that is 
> incorrectly named foo.jpg, then the file is treated as a JPEG. A 
> FileInputStream is opened and JPEGFactory.createFromStream then (correctly) 
> throws an IIOException. However, the FileInputStream is not closed.
> I saw that this is fixed in 3.0.0-SNAPSHOT:
> |if ("jpg".equals(ext) \|\| "jpeg".equals(ext))|
> |{|
> |try (FileInputStream fis = new FileInputStream(file))|
> |{
> return JPEGFactory.createFromStream(doc, fis);
> }|
> }
>  
> but if another 2.0.x release is made it would be good to include this.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to