diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index e3413e5..409be8a 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -3084,6 +3084,10 @@ void GfxUnivariateShading::getColor(double t, GfxColor *color) {
       out[i] = 0;
     }
     for (i = 0; i < nFuncs; ++i) {
+      if (funcs[i]->getInputSize() != 1) {
+        error(errSyntaxWarning, -1, "Invalid shading function (input != 1)");
+        break;
+      }
       funcs[i]->transform(&t, &out[i]);
     }
   }