File ImageMagick-CVE-2014-9828.patch of Package ImageMagick.8212

--- a/coders/psd.c
+++ b/coders/psd.c
@@ -1710,10 +1710,16 @@ static Image *ReadPSDImage(const ImageInfo *image_info,
         }
       else
         {
+          size_t
+            number_colors;
+
           /*
             Read PSD raster colormap.
           */
-          if (AcquireImageColormap(image,(size_t) (length/3)) == MagickFalse)
+          number_colors=length/3;
+          if (number_colors > 65536)
+            ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+          if (AcquireImageColormap(image,number_colors) == MagickFalse)
             ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
           for (i=0; i < (ssize_t) image->colors; i++)
             image->colormap[i].red=ScaleCharToQuantum((unsigned char)