75a61b
From 92e41685dcef538a7fc669ca357ce9f448a8078e Mon Sep 17 00:00:00 2001
75a61b
From: Albert Astals Cid <aacid@kde.org>
75a61b
Date: Sat, 7 Feb 2015 21:54:39 +0100
75a61b
Subject: Fix crash in malformed file from bug #85275
75a61b
75a61b
75a61b
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
75a61b
index 97af5c4..6640ab5 100644
75a61b
--- a/poppler/SplashOutputDev.cc
75a61b
+++ b/poppler/SplashOutputDev.cc
75a61b
@@ -4048,8 +4048,8 @@ void SplashOutputDev::setSoftMask(GfxState *state, double *bbox,
75a61b
   p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx;
75a61b
   int xMax = tBitmap->getWidth();
75a61b
   int yMax = tBitmap->getHeight();
75a61b
-  if (xMax + tx > bitmap->getWidth()) xMax = bitmap->getWidth() - tx;
75a61b
-  if (yMax + ty > bitmap->getHeight()) yMax = bitmap->getHeight() - ty;
75a61b
+  if (xMax > bitmap->getWidth() - tx) xMax = bitmap->getWidth() - tx;
75a61b
+  if (yMax > bitmap->getHeight() - ty) yMax = bitmap->getHeight() - ty;
75a61b
   for (y = 0; y < yMax; ++y) {
75a61b
     for (x = 0; x < xMax; ++x) {
75a61b
       if (alpha) {
75a61b
diff --git a/splash/Splash.cc b/splash/Splash.cc
75a61b
index fde272a..142516f 100644
75a61b
--- a/splash/Splash.cc
75a61b
+++ b/splash/Splash.cc
75a61b
@@ -11,7 +11,7 @@
75a61b
 // All changes made under the Poppler project to this file are licensed
75a61b
 // under GPL version 2 or later
75a61b
 //
75a61b
-// Copyright (C) 2005-2014 Albert Astals Cid <aacid@kde.org>
75a61b
+// Copyright (C) 2005-2015 Albert Astals Cid <aacid@kde.org>
75a61b
 // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com>
75a61b
 // Copyright (C) 2010-2014 Thomas Freitag <Thomas.Freitag@alfa.de>
75a61b
 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com>
75a61b
@@ -5214,6 +5214,10 @@ SplashError Splash::composite(SplashBitmap *src, int xSrc, int ySrc,
75a61b
     return splashErrModeMismatch;
75a61b
   }
75a61b
 
75a61b
+  if (unlikely(!bitmap->data)) {
75a61b
+    return splashErrZeroImage;
75a61b
+  }
75a61b
+
75a61b
   if(src->getSeparationList()->getLength() > bitmap->getSeparationList()->getLength()) {
75a61b
     for (x = bitmap->getSeparationList()->getLength(); x < src->getSeparationList()->getLength(); x++)
75a61b
       bitmap->getSeparationList()->append(((GfxSeparationColorSpace *)src->getSeparationList()->get(x))->copy());
75a61b
@@ -5783,6 +5787,10 @@ SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc,
75a61b
     return splashErrModeMismatch;
75a61b
   }
75a61b
 
75a61b
+  if (unlikely(!bitmap->data)) {
75a61b
+    return splashErrZeroImage;
75a61b
+  }
75a61b
+
75a61b
   switch (bitmap->mode) {
75a61b
   case splashModeMono1:
75a61b
     for (y = 0; y < h; ++y) {
75a61b
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
75a61b
index ac344f1..e886683 100644
75a61b
--- a/splash/SplashBitmap.cc
75a61b
+++ b/splash/SplashBitmap.cc
75a61b
@@ -11,7 +11,7 @@
75a61b
 // All changes made under the Poppler project to this file are licensed
75a61b
 // under GPL version 2 or later
75a61b
 //
75a61b
-// Copyright (C) 2006, 2009, 2010, 2012 Albert Astals Cid <aacid@kde.org>
75a61b
+// Copyright (C) 2006, 2009, 2010, 2012, 2015 Albert Astals Cid <aacid@kde.org>
75a61b
 // Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com>
75a61b
 // Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com>
75a61b
 // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
75a61b
@@ -275,7 +275,7 @@ SplashError SplashBitmap::writeAlphaPGMFile(char *fileName) {
75a61b
 void SplashBitmap::getPixel(int x, int y, SplashColorPtr pixel) {
75a61b
   SplashColorPtr p;
75a61b
 
75a61b
-  if (y < 0 || y >= height || x < 0 || x >= width) {
75a61b
+  if (y < 0 || y >= height || x < 0 || x >= width || !data) {
75a61b
     return;
75a61b
   }
75a61b
   switch (mode) {
75a61b
-- 
75a61b
cgit v0.10.2
75a61b