[
https://issues.apache.org/jira/browse/PDFBOX-2505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227877#comment-14227877
]
Tilman Hausherr commented on PDFBOX-2505:
-----------------------------------------
Thanks; I put checkArgumentSize in OperatorProcessor with the thought that we'd
have more such validators in the future.
> 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)