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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
tc33
Posts: 40
Joined: 2012-10-21T22:10:21-07:00
Authentication code: 67789

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

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post 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.
tc33
Posts: 40
Joined: 2012-10-21T22:10:21-07:00
Authentication code: 67789

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

Post by tc33 »

Awesome, thanks guys.
Post Reply