From: glennrp Date: Tue, 1 Jun 2010 13:07:15 +0000 (+0000) Subject: Handle zero ticks_per_second in accordance with MNG spec (set both X-Git-Tag: 7.0.1-0~9334 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb010dd620d8cf1743e64bc12f83e2bf1ffedddd;p=imagemagick Handle zero ticks_per_second in accordance with MNG spec (set both frame_delay and frame_timeout to PNG_UINT_31_MAX). --- diff --git a/ChangeLog b/ChangeLog index 14203cc38..deaae2576 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ * Add x:silent option to prevent beeps when reading the X image format. * Recognize TTF for GetMagicInfo(). * Ensure the +set option deletes the image artifact. + * Prevent MNG divide by zero in calculation of frame_timeout. Set + both frame_delay and frame_timeout to infinite when ticks_per_second + is zero, as required by the MNG spec. 2010-05-28 6.6.2.1 Glenn Randers-Pehrson * Prevent coders/png.c from attempting to write an empty tRNS chunk. diff --git a/coders/png.c b/coders/png.c index c885642da..a7bd06dbb 100644 --- a/coders/png.c +++ b/coders/png.c @@ -4457,6 +4457,8 @@ static Image *ReadMNGImage(const ImageInfo *image_info,ExceptionInfo *exception) mng_get_long(p); if (mng_info->ticks_per_second != 0) frame_delay/=mng_info->ticks_per_second; + else + frame_delay=PNG_UINT_31_MAX; if (change_delay == 2) default_frame_delay=frame_delay; p+=4; @@ -4466,8 +4468,12 @@ static Image *ReadMNGImage(const ImageInfo *image_info,ExceptionInfo *exception) } if (change_timeout) { - frame_timeout=(1UL*image->ticks_per_second* - (mng_get_long(p))/mng_info->ticks_per_second); + frame_timeout=1UL*image->ticks_per_second* + mng_get_long(p); + if (mng_info->ticks_per_second != 0) + frame_timeout/=mng_info->ticks_per_second; + else + frame_timeout=PNG_UINT_31_MAX; if (change_delay == 2) default_frame_timeout=frame_timeout; p+=4;