$OpenBSD: patch-kpdf_xpdf_GfxState_cc,v 1.1 2005/02/27 08:20:34 brad Exp $
--- kpdf/xpdf/GfxState.cc.orig	Sun Feb 27 02:58:50 2005
+++ kpdf/xpdf/GfxState.cc	Sun Feb 27 03:01:48 2005
@@ -708,6 +708,11 @@ GfxColorSpace *GfxICCBasedColorSpace::pa
   }
   nCompsA = obj2.getInt();
   obj2.free();
+  if (nCompsA > gfxColorMaxComps) {
+    error(-1, "ICCBased color space with too many (%d > %d) components",
+	  nCompsA, gfxColorMaxComps);
+    nCompsA = gfxColorMaxComps;
+  }
   if (dict->lookup("Alternate", &obj2)->isNull() ||
       !(altA = GfxColorSpace::parse(&obj2))) {
     switch (nCompsA) {
@@ -1054,7 +1059,7 @@ GfxColorSpace *GfxDeviceNColorSpace::par
   }
   nCompsA = obj1.arrayGetLength();
   if (nCompsA > gfxColorMaxComps) {
-    error(-1, "DeviceN color space with more than %d > %d components",
+    error(-1, "DeviceN color space with too many (%d > %d) components",
 	  nCompsA, gfxColorMaxComps);
     nCompsA = gfxColorMaxComps;
   }
