You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2014/11/18 21:54:35 UTC
[jira] [Commented] (PDFBOX-2505) ArrayIndexOutOfBoundsException in
PDColor constructor
[ https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14216779#comment-14216779 ]
John Hewson commented on PDFBOX-2505:
-------------------------------------
Invalid operators/operands are usually just skipped. Unless the PDF fails to render, that's what I'd do.
> ArrayIndexOutOfBoundsException in PDColor constructor
> -----------------------------------------------------
>
> Key: PDFBOX-2505
> URL: https://issues.apache.org/jira/browse/PDFBOX-2505
> Project: PDFBox
> Issue Type: Bug
> Components: Rendering
> Affects Versions: 2.0.0
> Reporter: Tilman Hausherr
> Fix For: 2.0.0
>
> Attachments: PDFBOX-2505-032618-p96.pdf
>
>
> {code}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.cos.COSArray.get(COSArray.java:210)
> at org.apache.pdfbox.pdmodel.graphics.color.PDColor.<init>(PDColor.java:54)
> at org.apache.pdfbox.contentstream.operator.color.SetColor.process(SetColor.java:41)
> at org.apache.pdfbox.contentstream.operator.color.SetNonStrokingDeviceCMYKColor.process(SetNonStrokingDeviceCMYKColor.java:38)
> {code}
> The attached file has a "k" without arguments.
> This is only in 2.0, not in 1.8. In 1.8 SetNonStrokingCMYKColor initializes the array with size 4 (ok, it will crash if there are 5 arguments), in 2.0 SetNonStrokingDeviceCMYKColor / SetColor take what is there.
> Two possible solutions in SetColor:
> 1) initialize "components" with the initial colors of the colorspace
> 2) initialize "components" with empty array
> Both solutions get rid of the exception. Solution 2 is used in another constructor.
> Which one is better? (I'd prefer solution 1 because it has the correct array size and would also change the other constructor)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)