From: Cristy Date: Wed, 26 Jul 2017 13:19:01 +0000 (-0400) Subject: https://patch-diff.githubusercontent.com/raw/ImageMagick/ImageMagick/pull/622 X-Git-Tag: 7.0.6-4~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;ds=sidebyside;h=e74d2e1b72b535ba32e7af9e6426d2a18b94f69f;p=imagemagick https://patch-diff.githubusercontent.com/raw/ImageMagick/ImageMagick/pull/622 --- diff --git a/coders/gif.c b/coders/gif.c index bbfd5b206..a08e5d95b 100644 --- a/coders/gif.c +++ b/coders/gif.c @@ -1109,10 +1109,11 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception) loop=LocaleNCompare((char *) buffer,"NETSCAPE2.0",11) == 0 ? MagickTrue : MagickFalse; if (loop != MagickFalse) + while (ReadBlobBlock(image,buffer) != 0) { - while (ReadBlobBlock(image,buffer) != 0) - iterations=(size_t) ((buffer[2] << 8) | buffer[1]); - break; + iterations=(size_t) ((buffer[2] << 8) | buffer[1]); + if (iterations != 0) + iterations++; } else { @@ -1739,7 +1740,7 @@ static MagickBooleanType WriteGIFImage(const ImageInfo *image_info,Image *image, (void) WriteBlob(image,11,(unsigned char *) "NETSCAPE2.0"); (void) WriteBlobByte(image,(unsigned char) 0x03); (void) WriteBlobByte(image,(unsigned char) 0x01); - (void) WriteBlobLSBShort(image,(unsigned short) image->iterations); + (void) WriteBlobLSBShort(image,(unsigned short) (image->iterations ? image->iterations - 1 : 0)); (void) WriteBlobByte(image,(unsigned char) 0x00); } if ((image->gamma != 1.0f/2.2f))