summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2016-10-24 20:04:00 +0200
committerAlbert Astals Cid <aacid@kde.org>2016-10-24 20:04:00 +0200
commit169889b8e196cfcd288e6555fb048fbbf95ba3f6 (patch)
treee71bf65fb0da5797265f14402e54c82353c24c25
parent269a91e3b03a19acc06fd0f72356f2e48a6368a7 (diff)
Fix crash on broken files
-rw-r--r--splash/Splash.cc38
1 files changed, 20 insertions, 18 deletions
diff --git a/splash/Splash.cc b/splash/Splash.cc
index e179c1cb..46b8ce29 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -5745,24 +5745,26 @@ GBool Splash::gouraudTriangleShadedFill(SplashGouraudColor *shading)
colorinterp = scanColorMap[0] * scanLimitL + scanColorMap[1];
bitmapOff = scanLineOff + scanLimitL * colorComps;
- for (int X = scanLimitL; X <= scanLimitR && bitmapOff + colorComps <= bitmapOffLimit; ++X, colorinterp += scanColorMap[0], bitmapOff += colorComps) {
- // FIXME : standard rectangular clipping can be done for a
- // complete scanline which is faster
- // --> see SplashClip and its methods
- if (!clip->test(X, Y))
- continue;
-
- assert(fabs(colorinterp - (scanColorMap[0] * X + scanColorMap[1])) < 1e-10);
- assert(bitmapOff == Y * rowSize + colorComps * X && scanLineOff == Y * rowSize);
-
- shading->getParameterizedColor(colorinterp, bitmapMode, &bitmapData[bitmapOff]);
-
- // make the shading visible.
- // Note that opacity is handled by the bDirectBlit stuff, see
- // above for comments and below for implementation.
- if (hasAlpha)
- bitmapAlpha[Y * bitmapWidth + X] = 255;
- }
+ if (likely(bitmapOff >= 0)) {
+ for (int X = scanLimitL; X <= scanLimitR && bitmapOff + colorComps <= bitmapOffLimit; ++X, colorinterp += scanColorMap[0], bitmapOff += colorComps) {
+ // FIXME : standard rectangular clipping can be done for a
+ // complete scanline which is faster
+ // --> see SplashClip and its methods
+ if (!clip->test(X, Y))
+ continue;
+
+ assert(fabs(colorinterp - (scanColorMap[0] * X + scanColorMap[1])) < 1e-10);
+ assert(bitmapOff == Y * rowSize + colorComps * X && scanLineOff == Y * rowSize);
+
+ shading->getParameterizedColor(colorinterp, bitmapMode, &bitmapData[bitmapOff]);
+
+ // make the shading visible.
+ // Note that opacity is handled by the bDirectBlit stuff, see
+ // above for comments and below for implementation.
+ if (hasAlpha)
+ bitmapAlpha[Y * bitmapWidth + X] = 255;
+ }
+ }
}
}
} else {