File ImageMagick-CVE-2014-9814.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-20 11:57:33.678907634 +0200
+++ ImageMagick-6.8.9-8/coders/wpg.c	2016-06-20 12:00:53.674158780 +0200
@@ -920,8 +920,7 @@ static Image *ReadWPGImage(const ImageIn
   */
 
   Image
-    *image,
-    *rotated_image;
+    *image;
 
   unsigned int
     status;
@@ -1151,30 +1150,43 @@ static Image *ReadWPGImage(const ImageIn
                   /* flop command */
                   if(BitmapHeader2.RotAngle & 0x8000)
                     {
-                      rotated_image = FlopImage(image, exception);
-                      rotated_image->blob = image->blob;
-                      DuplicateBlob(rotated_image,image);
-                      (void) RemoveLastImageFromList(&image);
-                      AppendImageToList(&image,rotated_image);
+                      Image
+                        *flop_image;
+
+                      flop_image = FlopImage(image, exception);
+                      if (flop_image != (Image *) NULL) {
+                        DuplicateBlob(flop_image,image);
+                        (void) RemoveLastImageFromList(&image);
+                        AppendImageToList(&image,flop_image);
+                      }
                     }
                   /* flip command */
                   if(BitmapHeader2.RotAngle & 0x2000)
                     {
-                      rotated_image = FlipImage(image, exception);
-                      rotated_image->blob = image->blob;
-                      DuplicateBlob(rotated_image,image);
-                      (void) RemoveLastImageFromList(&image);
-                      AppendImageToList(&image,rotated_image);
+                      Image
+                        *flip_image;
+
+                      flip_image = FlipImage(image, exception);
+                      if (flip_image != (Image *) NULL) {
+                        DuplicateBlob(flip_image,image);
+                        (void) RemoveLastImageFromList(&image);
+                        AppendImageToList(&image,flip_image);
+                      }
                     }
 
       /* rotate command */
                   if(BitmapHeader2.RotAngle & 0x0FFF)
                     {
-                      rotated_image = RotateImage(image, (BitmapHeader2.RotAngle & 0x0FFF), exception);
-                      rotated_image->blob = image->blob;
-                      DuplicateBlob(rotated_image,image);
-                      (void) RemoveLastImageFromList(&image);
-                      AppendImageToList(&image,rotated_image);
+                      Image
+                        *rotate_image;
+
+                      rotate_image=RotateImage(image,(BitmapHeader2.RotAngle &
+                        0x0FFF), exception);
+                      if (rotate_image != (Image *) NULL) {
+                        DuplicateBlob(rotate_image,image);
+                        (void) RemoveLastImageFromList(&image);
+                        AppendImageToList(&image,rotate_image);
+                      }
                     }
                 }
 
@@ -1327,12 +1339,16 @@ static Image *ReadWPGImage(const ImageIn
                 }
 
               if(CTM[0][0]<0 && !image_info->ping)
-    {    /*?? RotAngle=360-RotAngle;*/
-      rotated_image = FlopImage(image, exception);
-      rotated_image->blob = image->blob;
-      DuplicateBlob(rotated_image,image);
-      (void) RemoveLastImageFromList(&image);
-      AppendImageToList(&image,rotated_image);
+                {    /*?? RotAngle=360-RotAngle;*/
+                  Image
+                    *flop_image;
+
+                  flop_image = FlopImage(image, exception);
+                  if (flop_image != (Image *) NULL) {
+                    DuplicateBlob(flop_image,image);
+                    (void) RemoveLastImageFromList(&image);
+                    AppendImageToList(&image,flop_image);
+                  }
                   /* Try to change CTM according to Flip - I am not sure, must be checked.
                      Tx(0,0)=-1;      Tx(1,0)=0;   Tx(2,0)=0;
                      Tx(0,1)= 0;      Tx(1,1)=1;   Tx(2,1)=0;
@@ -1340,19 +1356,23 @@ static Image *ReadWPGImage(const ImageIn
                      Tx(1,2)=0;   Tx(2,2)=1; */
                 }
               if(CTM[1][1]<0 && !image_info->ping)
-    {    /*?? RotAngle=360-RotAngle;*/
-      rotated_image = FlipImage(image, exception);
-      rotated_image->blob = image->blob;
-      DuplicateBlob(rotated_image,image);
-      (void) RemoveLastImageFromList(&image);
-      AppendImageToList(&image,rotated_image);
+                {    /*?? RotAngle=360-RotAngle;*/
+                  Image
+                    *flip_image;
+
+                  flip_image = FlipImage(image, exception);
+                  if (flip_image != (Image *) NULL) {
+                    DuplicateBlob(flip_image,image);
+                    (void) RemoveLastImageFromList(&image);
+                    AppendImageToList(&image,flip_image);
+                  }
                   /* Try to change CTM according to Flip - I am not sure, must be checked.
                      float_matrix Tx(3,3);
                      Tx(0,0)= 1;   Tx(1,0)= 0;   Tx(2,0)=0;
                      Tx(0,1)= 0;   Tx(1,1)=-1;   Tx(2,1)=0;
                      Tx(0,2)= 0;   Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll);
                      Tx(2,2)=1; */
-    }
+                }
 
 
               /* Allocate next image structure. */