gif.c DecodeImage 8Bit Quantum Opacity Problem

Brian Rothstein <[email protected]> Sat, 6 Jun 2009 11:00:28 -0700
Newsgroups gmane.comp.video.image-magick.bugs
Message-ID <[email protected]>
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.