pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1813356 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/type1/Type1Parser.java
Date Wed, 25 Oct 2017 21:20:47 GMT
Author: tilman
Date: Wed Oct 25 21:20:47 2017
New Revision: 1813356

URL: http://svn.apache.org/viewvc?rev=1813356&view=rev
Log:
PDFBOX-3979: avoid NPE

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/type1/Type1Parser.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/type1/Type1Parser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/type1/Type1Parser.java?rev=1813356&r1=1813355&r2=1813356&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/type1/Type1Parser.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/type1/Type1Parser.java Wed Oct 25
21:20:47 2017
@@ -110,6 +110,10 @@ final class Type1Parser
         {
             // premature end
             Token token = lexer.peekToken();
+            if (token == null)
+            {
+                break;
+            }
             if (token.getKind() == Token.NAME &&
                 ("currentdict".equals(token.getText()) || "end".equals(token.getText())))
             {
@@ -312,12 +316,20 @@ final class Type1Parser
 
         for (int i = 0; i < length; i++)
         {
+            if (lexer.peekToken() == null)
+            {
+                break;
+            }
             if (lexer.peekToken().getKind() == Token.NAME &&
                !lexer.peekToken().getText().equals("end"))
             {
                 read(Token.NAME);
             }
             // premature end
+            if (lexer.peekToken() == null)
+            {
+                break;
+            }
             if (lexer.peekToken().getKind() == Token.NAME &&
                 lexer.peekToken().getText().equals("end"))
             {
@@ -501,7 +513,7 @@ final class Type1Parser
         for (int i = 0; i < length; i++)
         {
             // premature end
-            if (lexer.peekToken().getKind() != Token.LITERAL)
+            if (lexer.peekToken() == null || lexer.peekToken().getKind() != Token.LITERAL)
             {
                 break;
             }
@@ -633,6 +645,10 @@ final class Type1Parser
         for (int i = 0; i < length; i++)
         {
             // premature end
+            if (lexer.peekToken() == null)
+            {
+                break;
+            }
             if (!(lexer.peekToken().getKind() == Token.NAME &&
                   lexer.peekToken().getText().equals("dup")))
             {
@@ -691,6 +707,10 @@ final class Type1Parser
         for (int i = 0; i < length; i++)
         {
             // premature end
+            if (lexer.peekToken() == null)
+            {
+                break;
+            }
             if (lexer.peekToken().getKind() == Token.NAME &&
                 lexer.peekToken().getText().equals("end"))
             {



Mime
View raw message