Fix crash on malformed files
Bug #101502
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index b17925f..e6cd329 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -4036,6 +4036,12 @@
double out[gfxColorMaxComps];
int i, nComps;
+ if (unlikely(nFuncs < 1)) {
+ for (int i = 0; i < gfxColorMaxComps; i++)
+ color->c[i] = 0;
+ return;
+ }
+
// NB: there can be one function with n outputs or n functions with
// one output each (where n = number of color components)
nComps = nFuncs * funcs[0]->getOutputSize();
@@ -4089,6 +4095,9 @@
cacheBounds = NULL;
cacheSize = 0;
+ if (unlikely(nFuncs < 1))
+ return;
+
// NB: there can be one function with n outputs or n functions with
// one output each (where n = number of color components)
nComps = nFuncs * funcs[0]->getOutputSize();