File ImageMagick-CVE-2016-5688.patch of Package ImageMagick.8212

Index: ImageMagick-6.8.9-8/coders/wpg.c
===================================================================
--- ImageMagick-6.8.9-8.orig/coders/wpg.c	2016-06-22 11:47:31.989685865 +0200
+++ ImageMagick-6.8.9-8/coders/wpg.c	2016-06-22 11:47:32.041686705 +0200
@@ -1101,6 +1101,9 @@ static Image *ReadWPGImage(const ImageIn
               bpp=BitmapHeader2.Depth;
 
             UnpackRaster:
+              status=SetImageExtent(image,image->columns,image->rows);
+              if (status == MagickFalse)
+                break;
               if ((image->colors == 0) && (bpp != 24))
                 {
                   image->colors=one << bpp;
@@ -1296,6 +1299,10 @@ static Image *ReadWPGImage(const ImageIn
               image->columns=Bitmap2Header1.Width;
               image->rows=Bitmap2Header1.Heigth;
 
+              status=SetImageExtent(image,image->columns,image->rows);
+              if (status == MagickFalse)
+                break;
+
               if ((image->colors == 0) && (bpp != 24))
                 {
                   size_t
Index: ImageMagick-6.8.9-8/magick/cache.c
===================================================================
--- ImageMagick-6.8.9-8.orig/magick/cache.c	2016-06-22 11:47:31.985685800 +0200
+++ ImageMagick-6.8.9-8/magick/cache.c	2016-06-22 11:47:32.041686705 +0200
@@ -3674,6 +3674,7 @@ static MagickBooleanType OpenPixelCache(
             }
         }
       RelinquishMagickResource(DiskResource,cache_info->length);
+      cache_info->type=UndefinedCache;
       (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
         "CacheResourcesExhausted","`%s'",image->filename);
       return(MagickFalse);
@@ -3686,6 +3687,7 @@ static MagickBooleanType OpenPixelCache(
   if (OpenPixelCacheOnDisk(cache_info,mode) == MagickFalse)
     {
       RelinquishMagickResource(DiskResource,cache_info->length);
+      cache_info->type=UndefinedCache;
       ThrowFileException(exception,CacheError,"UnableToOpenPixelCache",
         image->filename);
       return(MagickFalse);
@@ -3694,6 +3696,7 @@ static MagickBooleanType OpenPixelCache(
     cache_info->length);
   if (status == MagickFalse)
     {
+      cache_info->type=UndefinedCache;
       ThrowFileException(exception,CacheError,"UnableToExtendCache",
         image->filename);
       return(MagickFalse);