diff -ru gd-2.0.35.orig/gd_gd.c gd-2.0.35/gd_gd.c --- gd-2.0.35.orig/gd_gd.c 2006-04-05 17:52:22.000000000 +0200 +++ gd-2.0.35/gd_gd.c 2009-11-09 11:57:01.000000000 +0100 @@ -44,6 +44,10 @@ { goto fail1; } + if (im->colorsTotal > gdMaxColors) + { + goto fail1; + } } /* Int to accommodate truecolor single-color transparency */ if (!gdGetInt (&im->transparent, in))