pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1780412 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
Date Thu, 26 Jan 2017 15:54:19 GMT
Author: tilman
Date: Thu Jan 26 15:54:19 2017
New Revision: 1780412

URL: http://svn.apache.org/viewvc?rev=1780412&view=rev
Log:
PDFBOX-3663: avoid NPE if /AcroForm exists without /Fields

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1780412&r1=1780411&r2=1780412&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Thu
Jan 26 15:54:19 2017
@@ -283,18 +283,17 @@ public class PDDocument implements Close
             acroForm.getCOSObject().setNeedToBeUpdated(true);
         }
 
-        List<PDField> fields = acroForm.getFields();
-        if (fields == null)
+        PDSignatureField signatureField = null;
+        if (!(acroForm.getCOSObject().getDictionaryObject(COSName.FIELDS) instanceof COSArray))
         {
-            fields = new ArrayList<PDField>();
-            acroForm.setFields(fields);
+            acroForm.getCOSObject().setItem(COSName.FIELDS, new COSArray());
         }
         else
         {
             COSArray fieldArray = (COSArray) acroForm.getCOSObject().getDictionaryObject(COSName.FIELDS);
             fieldArray.setNeedToBeUpdated(true);
+            signatureField = findSignatureField(acroForm.getFields(), sigObject);
         }
-        PDSignatureField signatureField = findSignatureField(fields, sigObject);
         if (signatureField == null)
         {
             signatureField = new PDSignatureField(acroForm);



Mime
View raw message