File ImageMagick-histogram.c-update.patch of Package ImageMagick.8212

--- ImageMagick-6.8.8-1/coders/histogram.c	2013-12-01 15:47:50.000000000 +0100
+++ /home/pgajdos/osc/home:pgajdos:magick/ImageMagick/ImageMagick-6.9.9-34/coders/histogram.c	2018-01-22 16:19:43.000000000 +0100
@@ -292,7 +284,9 @@ static MagickBooleanType WriteHISTOGRAMI
     if (((channel & BlueChannel) != 0) && (maximum < histogram[x].blue))
       maximum=histogram[x].blue;
   }
-  scale=(MagickRealType) histogram_image->rows/maximum;
+  scale=0.0;
+  if (fabs(maximum) >= MagickEpsilon)
+    scale=(MagickRealType) histogram_image->rows/maximum;
   /*
     Initialize histogram image.
   */
@@ -346,7 +340,9 @@ static MagickBooleanType WriteHISTOGRAMI
   */
   histogram=(MagickPixelPacket *) RelinquishMagickMemory(histogram);
   option=GetImageOption(image_info,"histogram:unique-colors");
-  if ((option == (const char *) NULL) || (IsMagickTrue(option) != MagickFalse))
+  if ((IsHistogramImage(image,exception) != MagickFalse) ||
+      (IsMagickTrue(option) != MagickFalse) ||
+      (GetImageOption(image_info,"format") != (const char *) NULL))
     {
       FILE
         *file;
@@ -382,9 +378,12 @@ static MagickBooleanType WriteHISTOGRAMI
   */
   (void) CopyMagickString(histogram_image->filename,image_info->filename,
     MaxTextExtent);
+  (void) ResetImagePage(histogram_image,"0x0+0+0");
   write_info=CloneImageInfo(image_info);
+  *write_info->magick='\0';
   (void) SetImageInfo(write_info,1,&image->exception);
-  if (LocaleCompare(write_info->magick,"HISTOGRAM") == 0)
+  if ((*write_info->magick == '\0') ||
+      (LocaleCompare(write_info->magick,"HISTOGRAM") == 0))
     (void) FormatLocaleString(histogram_image->filename,MaxTextExtent,
       "miff:%s",write_info->filename);
   status=WriteImage(write_info,histogram_image);