pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1846172 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java
Date Thu, 08 Nov 2018 17:21:52 GMT
Author: tilman
Date: Thu Nov  8 17:21:52 2018
New Revision: 1846172

URL: http://svn.apache.org/viewvc?rev=1846172&view=rev
Log:
PDFBOX-4372: return empty resources if resource key does exist but doesn't contain a dictionary,
to avoid stack overflow when form contains reference to form with its own name

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java?rev=1846172&r1=1846171&r2=1846172&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java
Thu Nov  8 17:21:52 2018
@@ -94,10 +94,17 @@ public class PDXObjectForm extends PDXOb
     public PDResources getResources()
     {
         PDResources retval = null;
-        COSDictionary resources = (COSDictionary) getCOSStream().getDictionaryObject(COSName.RESOURCES);
-        if (resources != null)
+        COSBase base = getCOSStream().getDictionaryObject(COSName.RESOURCES);
+        if (base instanceof COSDictionary)
         {
-            retval = new PDResources(resources);
+            retval = new PDResources((COSDictionary) base);
+        }
+        else if (getCOSStream().containsKey(COSName.RESOURCES))
+        {
+            // PDFBOX-4372 if the resource key exists but has nothing, return empty resources,
+            // to avoid a self-reference (xobject form Fm0 contains "/Fm0 Do")
+            // See also the mention of PDFBOX-1359 in PDFStreamEngine
+            retval = new PDResources();
         }
         return retval;
     }



Mime
View raw message