poppler/SplashOutputDev.cc |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 1da2091807ae7f7d4d3f446953c41b4c440d4b1b
Author: Albert Astals Cid <[EMAIL PROTECTED]>
Date:   Thu Jan 31 23:52:20 2008 +0100

    Ensure we don't draw outside the main bitmap on SplashOutputDev::setSoftMask
    
    Fixes crash on http://bugs.kde.org/show_bug.cgi?id=157000

diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 5315bfc..9aa99db 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -2653,8 +2653,12 @@ void SplashOutputDev::setSoftMask(GfxState * /*state*/, 
double * /*bbox*/,
   memset(softMask->getDataPtr(), 0,
         softMask->getRowSize() * softMask->getHeight());
   p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx;
-  for (y = 0; y < tBitmap->getHeight(); ++y) {
-    for (x = 0; x < tBitmap->getWidth(); ++x) {
+  int xMax = tBitmap->getWidth();
+  int yMax = tBitmap->getHeight();
+  if (xMax + tx > bitmap->getWidth()) xMax = bitmap->getWidth() - tx;
+  if (yMax + ty > bitmap->getHeight()) yMax = bitmap->getHeight() - ty;
+  for (y = 0; y < yMax; ++y) {
+    for (x = 0; x < xMax; ++x) {
       tBitmap->getPixel(x, y, color);
       if (alpha) {
        //~ unimplemented
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to