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

Index: ImageMagick-6.8.9-8/coders/viff.c
===================================================================
--- ImageMagick-6.8.9-8.orig/coders/viff.c      2014-05-18 13:36:56.000000000 +0200
+++ ImageMagick-6.8.9-8/coders/viff.c   2016-06-14 10:30:58.725647554 +0200
@@ -695,12 +673,18 @@ static Image *ReadVIFFImage(const ImageI
               SetPixelBlue(q,ScaleCharToQuantum(*(p+2*number_pixels)));
               if (image->colors != 0)
                 {
-                  SetPixelRed(q,image->colormap[(ssize_t)
-                    GetPixelRed(q)].red);
-                  SetPixelGreen(q,image->colormap[(ssize_t)
-                    GetPixelGreen(q)].green);
-                  SetPixelBlue(q,image->colormap[(ssize_t)
-                    GetPixelBlue(q)].blue);
+                   ssize_t
+                     index;
+
+                   index=(ssize_t) GetPixelRed(q);
+                   SetPixelRed(q,image->colormap[
+                     ConstrainColormapIndex(image,index)].red);
+                   index=(ssize_t) GetPixelGreen(q);
+                   SetPixelGreen(q,image->colormap[
+                     ConstrainColormapIndex(image,index)].green);
+                   index=(ssize_t) GetPixelRed(q);
+                   SetPixelBlue(q,image->colormap[
+                     ConstrainColormapIndex(image,index)].blue);
                 }
               SetPixelOpacity(q,image->matte != MagickFalse ?
                 QuantumRange-ScaleCharToQuantum(*(p+number_pixels*3)) :