76f8c5
From e465d36b8ecf46b80af4ac6b941ae56eb4883a89 Mon Sep 17 00:00:00 2001
76f8c5
From: Albert Astals Cid <aacid@kde.org>
76f8c5
Date: Mon, 19 Jun 2017 23:35:29 +0200
76f8c5
Subject: [PATCH] Fix crash on malformed files
76f8c5
76f8c5
Bug #101502
76f8c5
---
76f8c5
 poppler/GfxState.cc | 9 +++++++++
76f8c5
 1 file changed, 9 insertions(+)
76f8c5
76f8c5
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
76f8c5
index b17925f..e6cd329 100644
76f8c5
--- a/poppler/GfxState.cc
76f8c5
+++ b/poppler/GfxState.cc
76f8c5
@@ -4036,6 +4036,12 @@ void GfxUnivariateShading::getColor(double t, GfxColor *color) {
76f8c5
   double out[gfxColorMaxComps];
76f8c5
   int i, nComps;
76f8c5
 
76f8c5
+  if (unlikely(nFuncs < 1)) {
76f8c5
+    for (int i = 0; i < gfxColorMaxComps; i++)
76f8c5
+        color->c[i] = 0;
76f8c5
+    return;
76f8c5
+  }
76f8c5
+
76f8c5
   // NB: there can be one function with n outputs or n functions with
76f8c5
   // one output each (where n = number of color components)
76f8c5
   nComps = nFuncs * funcs[0]->getOutputSize();
76f8c5
@@ -4089,6 +4095,9 @@ void GfxUnivariateShading::setupCache(const Matrix *ctm,
76f8c5
   cacheBounds = NULL;
76f8c5
   cacheSize = 0;
76f8c5
 
76f8c5
+  if (unlikely(nFuncs < 1))
76f8c5
+    return;
76f8c5
+
76f8c5
   // NB: there can be one function with n outputs or n functions with
76f8c5
   // one output each (where n = number of color components)
76f8c5
   nComps = nFuncs * funcs[0]->getOutputSize();
76f8c5
-- 
76f8c5
2.9.3
76f8c5