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

Null pointer Exception with org.apache.fontbox.cff.CFFParser$DictData.getEntry(CFFParser.java:626)

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.0
    • Component/s: FontBox
    • Labels:
      None
    • Environment:
      Not an issue,

      Description

      The code doesn't crash, however there are a lot of stack dumps in the log file.

      The 4 entry in the array below has a null for an operator

      org.apache.fontbox.cff.CFFParser$DictData$Entry[operands=[-18, 18, 608, 18, -248, 16, 262, 10], operator=BlueValues],
      org.apache.fontbox.cff.CFFParser$DictData$Entry[operands=[240, 2, 114, 0, -576, 0], operator=OtherBlues],
      org.apache.fontbox.cff.CFFParser$DictData$Entry[operands=[0.0479583], operator=BlueScale],
      org.apache.fontbox.cff.CFFParser$DictData$Entry[operands=[0.06], operator=null],
      org.apache.fontbox.cff.CFFParser$DictData$Entry[operands=[278], operator=defaultWidthX],
      org.apache.fontbox.cff.CFFParser$DictData$Entry[operands=[551], operator=nominalWidthX], null, null, null, null

      In the file org.apache.fontbox.cff.CFFParser.java:626 it fails to test for a null operator.
      I am not sure if the data is incorrect or if the code should just test for a null pointer exception.

      • Failed to create Type1C font. Falling back to Type1 font
        java.lang.NullPointerException
        at org.apache.fontbox.cff.CFFParser$DictData.getEntry(CFFParser.java:626)
        at org.apache.fontbox.cff.CFFParser$DictData.getEntry(CFFParser.java:619)
        at org.apache.fontbox.cff.CFFParser.getDelta(CFFParser.java:414)
        at org.apache.fontbox.cff.CFFParser.parseFont(CFFParser.java:358)
        at org.apache.fontbox.cff.CFFParser.parse(CFFParser.java:66)

      Proposed fix would be to test for a null operator and stop the crash.

      private Entry getEntry(CFFOperator operator)
      {
      for (Entry entry : entries)
      {
      // Check for null entry before comparing the Font
      //

      if (entry != null && entry.operator != null &&
      entry.operator.equals(operator))

      { return entry; }

      }
      return null;
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              peter_lenahan@ibi.com Peter_Lenahan@ibi.com
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: