Details
Description
Parsing an invalid PDF can lead to a NullPointerException in COSParser
Steps to repro
- Download malformed PDF (attached)
- Run: java -jar pdfbox-app-2.0.16.jar ExtractText NullPtrException.pdf
Stacktrace
Exception in thread "main" java.lang.NullPointerException at java.base/java.util.TreeMap.getEntry(TreeMap.java:345) at java.base/java.util.TreeMap.get(TreeMap.java:277) at org.apache.pdfbox.pdfparser.COSParser.parseDictObjects(COSParser.java:727) at org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:187) at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:226) at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1070) at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1008) at org.apache.pdfbox.tools.ExtractText.startExtraction(ExtractText.java:216) at org.apache.pdfbox.tools.ExtractText.main(ExtractText.java:96) at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:60)