Fix misuse of ImageMagick that caused core dump.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Mar 2013 17:35:29 +0000 (09:35 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Mar 2013 17:35:29 +0000 (09:35 -0800)
* image.c (imagemagick_load_image): Calculate height and width
after flattening the image, not before.

Fixes: debbugs:13846

src/ChangeLog
src/image.c

index 2d6ddb9..08fd647 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-04  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Fix misuse of ImageMagick that caused core dump (Bug#13846).
+       * image.c (imagemagick_load_image): Calculate height and width
+       after flattening the image, not before.
+
 2013-03-04  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * font.c (Ffont_get_glyphs): Use convenient LGLYPH_NEW.
index 726b65d..2d4e7e7 100644 (file)
@@ -7792,11 +7792,6 @@ imagemagick_load_image (struct frame *f, struct image *img,
         }
     }
 
-  /* Finally we are done manipulating the image.  Figure out the
-     resulting width/height and transfer ownership to Emacs.  */
-  height = MagickGetImageHeight (image_wand);
-  width = MagickGetImageWidth (image_wand);
-
   /* Set the canvas background color to the frame or specified
      background, and flatten the image.  Note: as of ImageMagick
      6.6.0, SVG image transparency is not handled properly
@@ -7813,6 +7808,11 @@ imagemagick_load_image (struct frame *f, struct image *img,
     image_wand = new_wand;
   }
 
+  /* Finally we are done manipulating the image.  Figure out the
+     resulting width/height and transfer ownership to Emacs.  */
+  height = MagickGetImageHeight (image_wand);
+  width = MagickGetImageWidth (image_wand);
+
   if (! (width <= INT_MAX && height <= INT_MAX
         && check_image_size (f, width, height)))
     {