LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File ImageMagick-null-pointer-access.patch of Package ImageMagick (Project home:csbuild:DBA)

diff -up ImageMagick-6.7.8-9/magick/constitute.c.null-pointer-access ImageMagick-6.7.8-9/magick/constitute.c
--- ImageMagick-6.7.8-9/magick/constitute.c.null-pointer-access	2012-07-29 22:26:50.000000000 +0200
+++ ImageMagick-6.7.8-9/magick/constitute.c	2016-06-02 17:32:26.990718329 +0200
@@ -1324,7 +1324,7 @@ MagickExport MagickBooleanType WriteImag
     status;
 
   register Image
-    *p;
+    *p, *next_p;
 
   assert(image_info != (const ImageInfo *) NULL);
   assert(image_info->signature == MagickSignature);
@@ -1349,8 +1349,11 @@ MagickExport MagickBooleanType WriteImag
     sans_exception);
   sans_exception=DestroyExceptionInfo(sans_exception);
   p=images;
-  for ( ; GetNextImageInList(p) != (Image *) NULL; p=GetNextImageInList(p))
-    if (p->scene >= GetNextImageInList(p)->scene)
+  for ( ; GetNextImageInList(p) != (Image *) NULL; p=GetNextImageInList(p)) {
+    next_p = GetNextImageInList(p);
+    if (next_p == (Image *) NULL)
+      break;
+    if (p->scene >= next_p->scene)
       {
         register ssize_t
           i;
@@ -1363,6 +1366,7 @@ MagickExport MagickBooleanType WriteImag
           p->scene=(size_t) i++;
         break;
       }
+  }
   /*
     Write images.
   */