pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1806360 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java
Date Sun, 27 Aug 2017 12:46:57 GMT
Author: tilman
Date: Sun Aug 27 12:46:56 2017
New Revision: 1806360

URL: http://svn.apache.org/viewvc?rev=1806360&view=rev
Log:
PDFBOX-2852: avoid ClassCastException

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java?rev=1806360&r1=1806359&r2=1806360&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java
Sun Aug 27 12:46:56 2017
@@ -158,8 +158,9 @@ public class PDAnnotationLine extends PD
         {
             style = LE_NONE;
         }
-        COSArray array = (COSArray) getCOSObject().getDictionaryObject(COSName.LE);
-        if (array == null)
+        COSBase base = getCOSObject().getDictionaryObject(COSName.LE);
+        COSArray array;
+        if (!(base instanceof COSArray) || ((COSArray) base).size() == 0)
         {
             array = new COSArray();
             array.add(COSName.getPDFName(style));
@@ -168,6 +169,7 @@ public class PDAnnotationLine extends PD
         }
         else
         {
+            array = (COSArray) base;
             array.setName(0, style);
         }
     }
@@ -179,14 +181,12 @@ public class PDAnnotationLine extends PD
      */
     public String getStartPointEndingStyle()
     {
-        String retval = LE_NONE;
-        COSArray array = (COSArray) getCOSObject().getDictionaryObject(COSName.LE);
-        if (array != null)
+        COSBase base = getCOSObject().getDictionaryObject(COSName.LE);
+        if (base instanceof COSArray && ((COSArray) base).size() >= 2)
         {
-            retval = array.getName(0);
+            return ((COSArray) base).getName(0);
         }
-
-        return retval;
+        return LE_NONE;
     }
 
     /**
@@ -200,8 +200,9 @@ public class PDAnnotationLine extends PD
         {
             style = LE_NONE;
         }
-        COSArray array = (COSArray) getCOSObject().getDictionaryObject(COSName.LE);
-        if (array == null)
+        COSBase base = getCOSObject().getDictionaryObject(COSName.LE);
+        COSArray array;
+        if (!(base instanceof COSArray) || ((COSArray) base).size() < 2)
         {
             array = new COSArray();
             array.add(COSName.getPDFName(LE_NONE));
@@ -210,6 +211,7 @@ public class PDAnnotationLine extends PD
         }
         else
         {
+            array = (COSArray) base;
             array.setName(1, style);
         }
     }
@@ -221,14 +223,12 @@ public class PDAnnotationLine extends PD
      */
     public String getEndPointEndingStyle()
     {
-        String retval = LE_NONE;
-        COSArray array = (COSArray) getCOSObject().getDictionaryObject(COSName.LE);
-        if (array != null)
+        COSBase base = getCOSObject().getDictionaryObject(COSName.LE);
+        if (base instanceof COSArray && ((COSArray) base).size() >= 2)
         {
-            retval = array.getName(1);
+            return ((COSArray) base).getName(1);
         }
-
-        return retval;
+        return LE_NONE;
     }
 
     /**



Mime
View raw message