summaryrefslogtreecommitdiff
path: root/print/poppler/patches/patch-bc
blob: d3eec7b10cd15a2735c38e9585e7381153e82238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
$NetBSD: patch-bc,v 1.1 2009/03/19 12:12:24 drochner Exp $

--- poppler/Annot.cc.orig	2009-02-09 00:28:40.000000000 +0100
+++ poppler/Annot.cc
@@ -456,49 +456,67 @@ AnnotBorderArray::AnnotBorderArray(Array
   Object obj1;
   int arrayLength = array->getLength();
 
-  if (arrayLength >= 3) {
+  GBool correct = gTrue;
+  if (arrayLength == 3 || arrayLength == 4) {
     // implementation note 81 in Appendix H.
 
     if (array->get(0, &obj1)->isNum())
       horizontalCorner = obj1.getNum();
+    else
+      correct = gFalse;
     obj1.free();
 
     if (array->get(1, &obj1)->isNum())
       verticalCorner = obj1.getNum();
+    else
+      correct = gFalse;
     obj1.free();
 
     if (array->get(2, &obj1)->isNum())
       width = obj1.getNum();
+    else
+      correct = gFalse;
     obj1.free();
 
     // TODO: check not all zero ? (Line Dash Pattern Page 217 PDF 8.1)
-    if (arrayLength > 3) {
-      GBool correct = gTrue;
-      int tempLength = array->getLength() - 3;
-      double *tempDash = (double *) gmallocn (tempLength, sizeof (double));
+    if (arrayLength == 4) {
+      if (array->get(3, &obj1)->isArray()) {
+        Array *dashPattern = obj1.getArray();
+        int tempLength = dashPattern->getLength();
+        double *tempDash = (double *) gmallocn (tempLength, sizeof (double));
+
+        for(int i = 0; i < tempLength && i < DASH_LIMIT && correct; i++) {
 
-      for(int i = 0; i < tempLength && i < DASH_LIMIT && correct; i++) {
+          if (dashPattern->get(i, &obj1)->isNum()) {
+            tempDash[i] = obj1.getNum();
 
-        if (array->get((i + 3), &obj1)->isNum()) {
-          tempDash[i] = obj1.getNum();
+            if (tempDash[i] < 0)
+              correct = gFalse;
 
-          if (tempDash[i] < 0)
+          } else {
             correct = gFalse;
+          }
+          obj1.free();
+        }
 
+        if (correct) {
+          dashLength = tempLength;
+          dash = tempDash;
+          style = borderDashed;
         } else {
-          correct = gFalse;
+          gfree (tempDash);
         }
-        obj1.free();
-      }
-
-      if (correct) {
-        dashLength = tempLength;
-        dash = tempDash;
-        style = borderDashed;
       } else {
-        gfree (tempDash);
+        correct = gFalse;
       }
+      obj1.free();
     }
+  } else {
+    correct = gFalse;
+  }
+  
+  if (!correct) {
+    width = 0;
   }
 }