afb210
--- gd-2.0.28/gd_gd.c	2004-05-24 17:28:12.000000000 +0200
afb210
+++ gd-2.0.28_new/gd_gd.c	2009-12-08 15:19:16.159836680 +0100
afb210
@@ -44,6 +44,9 @@
afb210
 	    {
afb210
 	      goto fail1;
afb210
 	    }
afb210
+	    if (im->colorsTotal > gdMaxColors) {
afb210
+	      goto fail1;
afb210
+		}
afb210
 	}
afb210
       /* Int to accommodate truecolor single-color transparency */
afb210
       if (!gdGetInt (&im->transparent, in))