[ https://issues.apache.org/jira/browse/PDFBOX-2478?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tilman Hausherr updated PDFBOX-2478: ------------------------------------ Description: I get this with the file PDFBOX-2376-087731.pdf: {code} java.lang.NullPointerException PDFBOX-2376-179204-EMC.pdf at org.apache.pdfbox.preflight.xobject.XObjImageValidator.checkColorSpaceAndImageMask(XObjImageValidator.java:132) at org.apache.pdfbox.preflight.xobject.XObjImageValidator.validate(XObjImageValidator.java:183) at org.apache.pdfbox.preflight.process.reflect.GraphicObjectPageValidationProcess.validate(GraphicObjectPageValidationProcess.java:70) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) at org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:52) at org.apache.pdfbox.preflight.process.reflect.ResourcesValidationProcess.validateXObjects(ResourcesValidationProcess.java:288) at org.apache.pdfbox.preflight.process.reflect.ResourcesValidationProcess.validate(ResourcesValidationProcess.java:80) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) at org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:52) at org.apache.pdfbox.preflight.process.reflect.SinglePageValidationProcess.validateResources(SinglePageValidationProcess.java:167) at org.apache.pdfbox.preflight.process.reflect.SinglePageValidationProcess.validate(SinglePageValidationProcess.java:82) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) at org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:52) at org.apache.pdfbox.preflight.process.PageTreeValidationProcess.validatePage(PageTreeValidationProcess.java:56) at org.apache.pdfbox.preflight.process.PageTreeValidationProcess.validate(PageTreeValidationProcess.java:45) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) at org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:88) at org.apache.pdfbox.preflight.PreflightDocument.validate(PreflightDocument.java:168) at pdfboxpageimageextraction.PreflightTest.main(PreflightTest.java:47) {code} The cause is this piece of code: {code} Integer bitsPerCompValue = COSUtils.getAsInteger(bitsPerComp, cosDocument); if (bitsPerCompValue != 1) {code} which fails on this input: {code} 44 0 obj<</Length 289/Filter/CCITTFaxDecode/DecodeParms<</K -1/Columns 282/Rows 40>>/Width 282/Height 40/ImageMask true/Subtype/Image>> {code} That segment is called only for image masks. The spec does not require BitsPerComponent for image masks, but if it is there, it must be 1. So all I have to do is to add a null check. was: I get this with the file PDFBOX-2376-087731.pdf: {code} java.lang.NullPointerException PDFBOX-2376-179204-EMC.pdf at org.apache.pdfbox.preflight.xobject.XObjImageValidator.checkColorSpaceAndImageMask(XObjImageValidator.java:132) at org.apache.pdfbox.preflight.xobject.XObjImageValidator.validate(XObjImageValidator.java:183) at org.apache.pdfbox.preflight.process.reflect.GraphicObjectPageValidationProcess.validate(GraphicObjectPageValidationProcess.java:70) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) at org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:52) at org.apache.pdfbox.preflight.process.reflect.ResourcesValidationProcess.validateXObjects(ResourcesValidationProcess.java:288) at org.apache.pdfbox.preflight.process.reflect.ResourcesValidationProcess.validate(ResourcesValidationProcess.java:80) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) at org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:52) at org.apache.pdfbox.preflight.process.reflect.SinglePageValidationProcess.validateResources(SinglePageValidationProcess.java:167) at org.apache.pdfbox.preflight.process.reflect.SinglePageValidationProcess.validate(SinglePageValidationProcess.java:82) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) at org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:52) at org.apache.pdfbox.preflight.process.PageTreeValidationProcess.validatePage(PageTreeValidationProcess.java:56) at org.apache.pdfbox.preflight.process.PageTreeValidationProcess.validate(PageTreeValidationProcess.java:45) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) at org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:88) at org.apache.pdfbox.preflight.PreflightDocument.validate(PreflightDocument.java:168) at pdfboxpageimageextraction.PreflightTest.main(PreflightTest.java:47) {code} The cause is this piece of code: {code} Integer bitsPerCompValue = COSUtils.getAsInteger(bitsPerComp, cosDocument); if (bitsPerCompValue != 1) {code} which fails on this input: {code} 44 0 obj<</Length 289/Filter/CCITTFaxDecode/DecodeParms<</K -1/Columns 282/Rows 40>>/Width 282/Height 40/ImageMask true/Subtype/Image>> {code} That segment is called only for image masks. The spec does not require BitsPerComponent for image masks, but if they are there, they must be 1. So all I have to do is to add a null check. > NPE in XObjImageValidator.checkColorSpaceAndImageMask > ----------------------------------------------------- > > Key: PDFBOX-2478 > URL: https://issues.apache.org/jira/browse/PDFBOX-2478 > Project: PDFBox > Issue Type: Bug > Components: Preflight > Affects Versions: 1.8.7, 1.8.8, 2.0.0 > Reporter: Tilman Hausherr > Assignee: Tilman Hausherr > Fix For: 1.8.8, 2.0.0 > > > I get this with the file PDFBOX-2376-087731.pdf: > {code} > java.lang.NullPointerException > PDFBOX-2376-179204-EMC.pdf > at > org.apache.pdfbox.preflight.xobject.XObjImageValidator.checkColorSpaceAndImageMask(XObjImageValidator.java:132) > at > org.apache.pdfbox.preflight.xobject.XObjImageValidator.validate(XObjImageValidator.java:183) > at > org.apache.pdfbox.preflight.process.reflect.GraphicObjectPageValidationProcess.validate(GraphicObjectPageValidationProcess.java:70) > at > org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) > at > org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:52) > at > org.apache.pdfbox.preflight.process.reflect.ResourcesValidationProcess.validateXObjects(ResourcesValidationProcess.java:288) > at > org.apache.pdfbox.preflight.process.reflect.ResourcesValidationProcess.validate(ResourcesValidationProcess.java:80) > at > org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) > at > org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:52) > at > org.apache.pdfbox.preflight.process.reflect.SinglePageValidationProcess.validateResources(SinglePageValidationProcess.java:167) > at > org.apache.pdfbox.preflight.process.reflect.SinglePageValidationProcess.validate(SinglePageValidationProcess.java:82) > at > org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) > at > org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:52) > at > org.apache.pdfbox.preflight.process.PageTreeValidationProcess.validatePage(PageTreeValidationProcess.java:56) > at > org.apache.pdfbox.preflight.process.PageTreeValidationProcess.validate(PageTreeValidationProcess.java:45) > at > org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:73) > at > org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:88) > at > org.apache.pdfbox.preflight.PreflightDocument.validate(PreflightDocument.java:168) > at pdfboxpageimageextraction.PreflightTest.main(PreflightTest.java:47) > {code} > The cause is this piece of code: > {code} > Integer bitsPerCompValue = COSUtils.getAsInteger(bitsPerComp, > cosDocument); > if (bitsPerCompValue != 1) > {code} > which fails on this input: > {code} > 44 0 obj<</Length 289/Filter/CCITTFaxDecode/DecodeParms<</K -1/Columns > 282/Rows 40>>/Width 282/Height 40/ImageMask true/Subtype/Image>> > {code} > That segment is called only for image masks. The spec does not require > BitsPerComponent for image masks, but if it is there, it must be 1. So all I > have to do is to add a null check. -- This message was sent by Atlassian JIRA (v6.3.4#6332)