Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4624

COSParser: NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.16
    • 2.0.17
    • Parsing
    • None
    • java version "12" 2019-03-19
      Java(TM) SE Runtime Environment (build 12+33)
      Java HotSpot(TM) 64-Bit Server VM (build 12+33, mixed mode, sharing)

      MacOS Mojave

    Description

      Parsing an invalid PDF can lead to a NullPointerException in COSParser

      Steps to repro

      1. Download malformed PDF (attached)
      2. 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)

      Attachments

        1. NullPtrException.pdf
          4 kB
          Alex Rebert

        Activity

          People

            tilman Tilman Hausherr
            apr Alex Rebert
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: