<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">--- kpdf/xpdf/splash/SplashXPathScanner.cc	(Revision 505052)
+++ kpdf/xpdf/splash/SplashXPathScanner.cc	(Arbeitskopie)
@@ -186,7 +186,7 @@ GBool SplashXPathScanner::getNextSpan(in
 }
 
 void SplashXPathScanner::computeIntersections(int y) {
-  SplashCoord ySegMin, ySegMax, xx0, xx1;
+  SplashCoord xSegMin, xSegMax, ySegMin, ySegMax, xx0, xx1;
   SplashXPathSeg *seg;
   int i, j;
 
@@ -236,19 +236,27 @@ void SplashXPathScanner::computeIntersec
     } else if (seg-&gt;flags &amp; splashXPathVert) {
       xx0 = xx1 = seg-&gt;x0;
     } else {
-      if (ySegMin &lt;= y) {
-	// intersection with top edge
-	xx0 = seg-&gt;x0 + ((SplashCoord)y - seg-&gt;y0) * seg-&gt;dxdy;
+      if (seg-&gt;x0 &lt; seg-&gt;x1) {
+	xSegMin = seg-&gt;x0;
+	xSegMax = seg-&gt;x1;
       } else {
-	// x coord of segment endpoint with min y coord
-	xx0 = (seg-&gt;flags &amp; splashXPathFlip) ? seg-&gt;x1 : seg-&gt;x0;
+	xSegMin = seg-&gt;x1;
+	xSegMax = seg-&gt;x0;
       }
-      if (ySegMax &gt;= y + 1) {
-	// intersection with bottom edge
-	xx1 = seg-&gt;x0 + ((SplashCoord)y + 1 - seg-&gt;y0) * seg-&gt;dxdy;
-      } else {
-	// x coord of segment endpoint with max y coord
-	xx1 = (seg-&gt;flags &amp; splashXPathFlip) ? seg-&gt;x0 : seg-&gt;x1;
+      // intersection with top edge
+      xx0 = seg-&gt;x0 + ((SplashCoord)y - seg-&gt;y0) * seg-&gt;dxdy;
+      // intersection with bottom edge
+      xx1 = seg-&gt;x0 + ((SplashCoord)y + 1 - seg-&gt;y0) * seg-&gt;dxdy;
+      // the segment may not actually extend to the top and/or bottom edges
+      if (xx0 &lt; xSegMin) {
+	xx0 = xSegMin;
+      } else if (xx0 &gt; xSegMax) {
+	xx0 = xSegMax;
+      }
+      if (xx1 &lt; xSegMin) {
+	xx1 = xSegMin;
+      } else if (xx1 &gt; xSegMax) {
+	xx1 = xSegMax;
       }
     }
     if (xx0 &lt; xx1) {
</pre></body></html>