[
https://issues.apache.org/jira/browse/PDFBOX-898?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Adam Nichols resolved PDFBOX-898.
---------------------------------
Resolution: Fixed
Fix Version/s: 1.4.0
Assignee: Adam Nichols
I agree that creating an array of nothing doesn't make much sense. Patch
committed in revision 1037894. Thanks for the contributions.
> 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
> Assignee: Adam Nichols
> Fix For: 1.4.0
>
> 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.