File ImageMagick-CVE-2015-8898.patch of Package ImageMagick.8212

Index: ImageMagick-6.8.9-8/magick/constitute.c
===================================================================
--- ImageMagick-6.8.9-8.orig/magick/constitute.c	2014-09-20 15:25:52.000000000 +0200
+++ ImageMagick-6.8.9-8/magick/constitute.c	2016-06-09 12:41:28.170247035 +0200
@@ -1299,7 +1299,14 @@ MagickExport MagickBooleanType WriteImag
   sans_exception=DestroyExceptionInfo(sans_exception);
   p=images;
   for ( ; GetNextImageInList(p) != (Image *) NULL; p=GetNextImageInList(p))
-    if (p->scene >= GetNextImageInList(p)->scene)
+  {
+    register Image
+      *next;
+
+    next=GetNextImageInList(p);
+    if (next == (Image *) NULL)
+      break;
+    if (p->scene >= next->scene)
       {
         register ssize_t
           i;
@@ -1312,6 +1319,7 @@ MagickExport MagickBooleanType WriteImag
           p->scene=(size_t) i++;
         break;
       }
+  }
   /*
     Write images.
   */