[Magick-bugs] gif.c DecodeImage 8Bit Quantum Opacity Problem

Brian Rothstein brian.rothstein at gmail.com
Sat Jun 6 11:00:28 PDT 2009


The following code in gif.c is problematic in that when Quantums are 8-bit
unsigned chars, opacity will convert from -1 to 255.

So when this code is called in ReadGifImage with opacity==-1 (i.e. no
transparent color)

      status=DecodeImage(image,(Quantum) opacity);

This function

MagickBooleanType DecodeImage(Image *image,const Quantum opacity)

will see opacity as the 255th palette entry and this line

q->opacity=index == opacity ? (Quantum) TransparentOpacity :
        (Quantum) OpaqueOpacity;

will incorrectly set the opacity to transparent for the 255th palette entry.

Sorry if I haven't described this problem well.  I've never really
contributed to one of these projects before.  My fix, though, is to change
opacity to a long in DecodeImage and also to not type caste it to a Quantum
in the call to DecodeImage.


More information about the Magick-bugs mailing list