You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Martijn Brinkers (JIRA)" <ji...@apache.org> on 2010/11/20 12:48:13 UTC
[jira] Updated: (PDFBOX-898) COSStreamArray NullPointerException.
firstStream is null if COSArray contains no items
[ https://issues.apache.org/jira/browse/PDFBOX-898?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martijn Brinkers updated PDFBOX-898:
------------------------------------
Attachment: PDFBOX-898.patch
Patch to skip creating COSStreamArray if array is empty
> COSStreamArray NullPointerException. firstStream is null if COSArray contains no items
> --------------------------------------------------------------------------------------
>
> Key: PDFBOX-898
> URL: https://issues.apache.org/jira/browse/PDFBOX-898
> Project: PDFBox
> Issue Type: Bug
> Components: Parsing
> Affects Versions: 1.3.1
> Reporter: Martijn Brinkers
> Attachments: PDFBOX-898.patch
>
>
> COSStreamArray checks whether array contains any items. If array is empty firstStream is not set and therefore null.
> public COSStreamArray( COSArray array )
> {
> super( new COSDictionary(), null );
> streams = array;
> if( array.size() > 0 )
> {
> firstStream = (COSStream)array.getObject( 0 );
> }
> }
> Most methods of COSStreamArray however use firstStream without any checks which can result in a NullPointerException.
> I have a PDF that when parsed, results in a NPE because COSStreamArray#getScratchFile is called while firstStream is null.
> One option would be to not create an instance of COSStreamArray when there are no items in the array.
> A patch is attached that checks whether the array is empty and only creates an instance of there are any items.
> The PDF was created with:
> LaTeX with hyperref package
> PDF-1.2
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.