75a61b
From d9c88e1c8892c79b8865a0dabdcc0d3ffd55c195 Mon Sep 17 00:00:00 2001
75a61b
From: Albert Astals Cid <aacid@kde.org>
75a61b
Date: Wed, 21 Jun 2017 00:56:38 +0200
75a61b
Subject: [PATCH] Fix crash in malformed documents
75a61b
75a61b
---
75a61b
 poppler/GfxState.cc | 12 ++++++------
75a61b
 1 file changed, 6 insertions(+), 6 deletions(-)
75a61b
75a61b
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
75a61b
index e6cd329..f61f812 100644
75a61b
--- a/poppler/GfxState.cc
75a61b
+++ b/poppler/GfxState.cc
75a61b
@@ -4034,18 +4034,18 @@ GfxUnivariateShading::~GfxUnivariateShading() {
75a61b
 
75a61b
 void GfxUnivariateShading::getColor(double t, GfxColor *color) {
75a61b
   double out[gfxColorMaxComps];
75a61b
-  int i, nComps;
75a61b
+  int i;
75a61b
+
75a61b
+  // NB: there can be one function with n outputs or n functions with
75a61b
+  // one output each (where n = number of color components)
75a61b
+  const int nComps = nFuncs * funcs[0]->getOutputSize();
75a61b
 
75a61b
-  if (unlikely(nFuncs < 1)) {
75a61b
+  if (unlikely(nFuncs < 1 || nComps > gfxColorMaxComps)) {
75a61b
     for (int i = 0; i < gfxColorMaxComps; i++)
75a61b
         color->c[i] = 0;
75a61b
     return;
75a61b
   }
75a61b
 
75a61b
-  // NB: there can be one function with n outputs or n functions with
75a61b
-  // one output each (where n = number of color components)
75a61b
-  nComps = nFuncs * funcs[0]->getOutputSize();
75a61b
-
75a61b
   if (cacheSize > 0) {
75a61b
     double x, ix, *l, *u, *upper;
75a61b
 
75a61b
-- 
75a61b
2.9.3
75a61b