pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1615744 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter: FlateFilter.java LZWFilter.java
Date Mon, 04 Aug 2014 19:42:56 GMT
Author: jahewson
Date: Mon Aug  4 19:42:56 2014
New Revision: 1615744

URL: http://svn.apache.org/r1615744
Log:
PDFBOX-1268: OutOfMemory Error because of huge colors

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java?rev=1615744&r1=1615743&r2=1615744&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilter.java Mon Aug  4
19:42:56 2014
@@ -58,7 +58,7 @@ final class FlateFilter extends Filter
         {
             if (predictor > 1)
             {
-                int colors = decodeParams.getInt(COSName.COLORS, 1);
+                int colors = Math.min(decodeParams.getInt(COSName.COLORS, 1), 32);
                 int bitsPerPixel = decodeParams.getInt(COSName.BITS_PER_COMPONENT, 8);
                 int columns = decodeParams.getInt(COSName.COLUMNS, 1);
                 ByteArrayOutputStream baos = new ByteArrayOutputStream();

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java?rev=1615744&r1=1615743&r2=1615744&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/LZWFilter.java Mon Aug  4 19:42:56
2014
@@ -79,7 +79,7 @@ public class LZWFilter extends Filter
         }
         if (predictor > 1)
         {
-            int colors = decodeParams.getInt(COSName.COLORS, 1);
+            int colors = Math.min(decodeParams.getInt(COSName.COLORS, 1), 32);
             int bitsPerPixel = decodeParams.getInt(COSName.BITS_PER_COMPONENT, 8);
             int columns = decodeParams.getInt(COSName.COLUMNS, 1);
             ByteArrayOutputStream baos = new ByteArrayOutputStream();



Mime
View raw message