ICEpdf
  1. ICEpdf
  2. PDF-1010

java.lang.NullPointerException thrown when try to open some PDFs

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.1.2
    • Fix Version/s: 6.1.3
    • Component/s: Core/Parsing
    • Labels:
      None
    • Environment:
      All
    • Workaround Exists:
      Yes
    • Workaround Description:
      Hide
      If I change convertToString in CMap class in the way below the PDF is showed. But I think that this is a workaround rather than a fix of the problem.

      private char[] convertToString(CharSequence s) {
              if (s == null && s.length() % 2 != 0) {
                  throw new IllegalArgumentException();
              }
              int len = s.length();
              if (len == 1) {
                  return new char[]{s.charAt(0)};
              }
              char[] dest = new char[len / 2];
              for (int i = 0, j = 0; i < len; i += 2, j++) {
                  dest[j] = (char) ((s.charAt(i) << 8) | s.charAt(i + 1));
              }
              return dest;
          }
      Show
      If I change convertToString in CMap class in the way below the PDF is showed. But I think that this is a workaround rather than a fix of the problem. private char[] convertToString(CharSequence s) {         if (s == null && s.length() % 2 != 0) {             throw new IllegalArgumentException();         }         int len = s.length();         if (len == 1) {             return new char[]{s.charAt(0)};         }         char[] dest = new char[len / 2];         for (int i = 0, j = 0; i < len; i += 2, j++) {             dest[j] = (char) ((s.charAt(i) << 8) | s.charAt(i + 1));         }         return dest;     }

      Description

      When rendering the provided PDF file the following exceptions are thrown and the content of the PDF is rendered blank:

      ICEsoft ICEpdf Viewer x.x.x x
      Copyright ICEsoft Technologies, Inc.

      lug 15, 2016 10:03:01 AM org.icepdf.core.pobjects.Catalog <clinit>
      INFORMAZIONI: ICEsoft ICEpdf Core x.x.x x
      lug 15, 2016 10:03:01 AM org.icepdf.core.pobjects.Resources getFont
      AVVERTENZA: Error initializing font, falling back to font substitution.
      lug 15, 2016 10:03:01 AM org.icepdf.core.util.content.AbstractContentParser consume_Tf
      AVVERTENZA: Warning could not find font by named resource C2_0
      lug 15, 2016 10:03:01 AM org.icepdf.core.pobjects.Resources getFont
      AVVERTENZA: Error initializing font, falling back to font substitution.
      lug 15, 2016 10:03:01 AM org.icepdf.core.util.content.AbstractContentParser consume_Tf
      AVVERTENZA: Warning could not find font by named resource C2_0
      lug 15, 2016 10:03:01 AM org.icepdf.core.util.content.NContentParser parse
      AVVERTENZA: Error parsing content stream.
      java.lang.NullPointerException
      at org.icepdf.core.util.content.AbstractContentParser.consume_Tf(AbstractContentParser.java:833)
      at org.icepdf.core.util.content.NContentParser.parse(NContentParser.java:174)
      at org.icepdf.core.pobjects.Page.init(Page.java:404)
      at org.icepdf.ri.common.views.PageViewComponentImpl$PageInitializer.run(PageViewComponentImpl.java:1180)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)

      The problem is that the convertToString method of CMap.java class receives a CharSequence s of length 1.

      P.S. Incidentally I noted that the same method contains a bug: if (s == null && s.length() % 2 != 0) I think should instead be if (s == null || s.length() % 2 != 0). But I don't think that is the problem.
      1. Atto2.pdf
        894 kB
        Giorgio Fiderio
      1. IcePDFTest.png
        414 kB

        Activity

          People

          • Assignee:
            Patrick Corless
            Reporter:
            Giorgio Fiderio
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: