From: Paul Eggert Date: Mon, 4 Mar 2013 17:35:29 +0000 (-0800) Subject: Fix misuse of ImageMagick that caused core dump. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~629 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=84ac6f9d211796a458214741bdf9677b92bf1c2a;p=emacs.git Fix misuse of ImageMagick that caused core dump. * image.c (imagemagick_load_image): Calculate height and width after flattening the image, not before. Fixes: debbugs:13846 --- diff --git a/src/ChangeLog b/src/ChangeLog index 2d6ddb9b06a..08fd647074f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2013-03-04 Paul Eggert + + 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 * font.c (Ffont_get_glyphs): Use convenient LGLYPH_NEW. diff --git a/src/image.c b/src/image.c index 726b65d7338..2d4e7e731ad 100644 --- a/src/image.c +++ b/src/image.c @@ -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))) {