Page 1 of 1

png.c : png:compression-filter = 0 causes exception

Posted: 2012-10-21T22:19:38-07:00
by tc33
Version 6.8.0.2

file: coders/png.c
line: 11364

Issue:
specifying a png:compression-filter value of "0" causes an exception to be thrown due to a missing 'else' statement on line 11364. "0" is a valid value for the operation.

code in png.c ( starts on line 11348 )

Code: Select all

value=GetImageArtifact(image,"png:compression-filter");
  if (value == NULL)
     value=GetImageOption(image_info,"png:compression-filter");
  if (value != NULL)
  {

      /* To do: combinations of filters allowed by libpng
       * masks 0x08 through 0xf8
       *
       * Implement this as a comma-separated list of 0,1,2,3,4,5
       * where 5 is a special case meaning PNG_ALL_FILTERS.
       */

      if (LocaleCompare(value,"0") == 0)
        mng_info->write_png_compression_filter = 1;

      if (LocaleCompare(value,"1") == 0)    // <--------------    SHOULDNT THERE BE AN 'ELSE' HERE?  VALUE 0 FALLS THROUGH TO THE EXCEPTION
        mng_info->write_png_compression_filter = 2;

      else if (LocaleCompare(value,"2") == 0)
        mng_info->write_png_compression_filter = 3;

      else if (LocaleCompare(value,"3") == 0)
        mng_info->write_png_compression_filter = 4;

      else if (LocaleCompare(value,"4") == 0)
        mng_info->write_png_compression_filter = 5;

      else if (LocaleCompare(value,"5") == 0)
        mng_info->write_png_compression_filter = 6;


      else
        (void) ThrowMagickException(&image->exception,
             GetMagickModule(),CoderWarning,
             "ignoring invalid defined png:compression-filter",
             "=%s",value);
    }
Steps to reproduce:
specify a value of 0 for png:compression-filter in an image option or image artifact

Thanks

Re: png.c : png:compression-filter = 0 causes exception

Posted: 2012-10-22T04:05:06-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.8.0-3 Beta available by sometime tomorrow. Thanks.

Re: png.c : png:compression-filter = 0 causes exception

Posted: 2012-10-22T05:34:36-07:00
by glennrp
tc33 wrote:
if (LocaleCompare(value,"1") == 0) // <-------------- SHOULDNT THERE BE AN 'ELSE' HERE? VALUE 0 FALLS THROUGH TO THE EXCEPTION
Yes, I agree.

Re: png.c : png:compression-filter = 0 causes exception

Posted: 2012-10-22T10:45:46-07:00
by tc33
Awesome, thanks guys.