Hello,

I faced the same bug here with the following files:

        http://citi.insa-lyon.fr/~iguerinl/routage.pdf
        http://citi.insa-lyon.fr/~iguerinl/technologies.pdf

The bug is located in SplashXPath::SplashXPath() (SplashXPath.cc),
around line 100.

The end condition of the while(1) loop is based on the (computed)
value of x0.  It looks like some rounding errors make that the loop
never ends.

The attached patch solves the problem by pre-computing the number of
iterations of the loop.

        Arnaud

--- xpdf-3.00/splash/SplashXPath.cc.orig        2004-01-22 02:26:44.000000000 
+0100
+++ xpdf-3.00/splash/SplashXPath.cc     2005-01-21 23:36:28.000000000 +0100
@@ -33,9 +33,8 @@
 SplashXPath::SplashXPath(SplashPath *path, SplashCoord flatness,
                         GBool closeSubpaths) {
   SplashCoord xc, yc, dx, dy, r, x0, y0, x1, y1;
-  int quad0, quad1, quad;
+  int quad0, quad1, quad, narcs;
   int i, curSubpath;
-  GBool last;
 
   segs = NULL;
   length = size = 0;
@@ -93,6 +92,16 @@
        } else {
          quad1 = 3;
        }
+       if (quad0 != quad1) {
+         narcs = 1 + (quad1 + 4 - quad0) % 4;
+       } else {
+         switch (quad0) {
+         case 0:
+         case 1: narcs = (path->pts[i+1].x > path->pts[i-1].x)? 1: 5; break;
+         case 2:
+         case 3: narcs = (path->pts[i+1].x < path->pts[i-1].x)? 1: 5; break;
+         }
+       }
        x0 = path->pts[i-1].x;
        y0 = path->pts[i-1].y;
        x1 = y1 = 0; // make gcc happy
@@ -104,16 +113,7 @@
          case 2: x1 = xc;     y1 = yc + r; break;
          case 3: x1 = xc - r; y1 = yc;     break;
          }
-         last = gFalse;
-         if (quad == quad1) {
-           switch (quad) {
-           case 0: 
-           case 1: last = path->pts[i+1].x > x0; break;
-           case 2:
-           case 3: last = path->pts[i+1].x < x0; break;
-           }
-         }
-         if (last) {
+         if (--narcs == 0) {
            addArc(x0, y0, path->pts[i+1].x, path->pts[i+1].y,
                   xc, yc, r, quad, flatness,
                   quad == quad0 && (path->flags[i-1] & splashPathFirst),

Reply via email to