pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1783575 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: contentstream/operator/graphics/BeginInlineImage.java pdfparser/PDFStreamParser.java
Date Sat, 18 Feb 2017 17:59:22 GMT
Author: tilman
Date: Sat Feb 18 17:59:22 2017
New Revision: 1783575

URL: http://svn.apache.org/viewvc?rev=1783575&view=rev
Log:
PDFBOX-3694: avoid NPE and ClassCastExcepton on empty inline images

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/BeginInlineImage.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/BeginInlineImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/BeginInlineImage.java?rev=1783575&r1=1783574&r2=1783575&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/BeginInlineImage.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/BeginInlineImage.java
Sat Feb 18 17:59:22 2017
@@ -34,7 +34,7 @@ public final class BeginInlineImage exte
     @Override
     public void process(Operator operator, List<COSBase> operands) throws IOException
     {
-        if (operator.getImageData().length == 0)
+        if (operator.getImageData() == null || operator.getImageData().length == 0)
         {
             return;
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java?rev=1783575&r1=1783574&r2=1783575&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java Sat
Feb 18 17:59:22 2017
@@ -285,12 +285,15 @@ public class PDFStreamParser extends Bas
                         imageParams.setItem( (COSName)nextToken, (COSBase)value );
                     }
                     //final token will be the image data, maybe??
-                    Operator imageData = (Operator)nextToken;
-                    if (imageData.getImageData().length == 0)
+                    if (nextToken instanceof Operator)
                     {
-                        LOG.warn("empty inline image at stream offset " + seqSource.getPosition());
+                        Operator imageData = (Operator) nextToken;
+                        if (imageData.getImageData() == null || imageData.getImageData().length
== 0)
+                        {
+                            LOG.warn("empty inline image at stream offset " + seqSource.getPosition());
+                        }
+                        beginImageOP.setImageData(imageData.getImageData());
                     }
-                    beginImageOP.setImageData( imageData.getImageData() );
                 }
                 break;
             }



Mime
View raw message