diff --git a/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp b/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp index 7c1613e64f8..81f2d842b68 100644 --- a/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp +++ b/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp @@ -460,19 +460,25 @@ int nsGIFDecoder2::HaveDecodedRow( case gfxIFormats::BGR: { while (rowBufIndex != decoder->mGIFStruct->rowend) { - PRUint32 colorIndex = (*rowBufIndex < cmapsize) ? (*rowBufIndex * 3) : 0; -#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON) - *rgbRowIndex++ = cmap[colorIndex + 2]; // blue - *rgbRowIndex++ = cmap[colorIndex + 1]; // green - *rgbRowIndex++ = cmap[colorIndex]; // red -#else #if defined(XP_MAC) || defined(XP_MACOSX) *rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad #endif - *rgbRowIndex++ = cmap[colorIndex]; // red - *rgbRowIndex++ = cmap[colorIndex + 1]; // green - *rgbRowIndex++ = cmap[colorIndex + 2]; // blue + if (*rowBufIndex < cmapsize) { + PRUint32 colorIndex = *rowBufIndex * 3; +#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON) + *rgbRowIndex++ = cmap[colorIndex + 2]; // blue + *rgbRowIndex++ = cmap[colorIndex + 1]; // green + *rgbRowIndex++ = cmap[colorIndex]; // red +#else + *rgbRowIndex++ = cmap[colorIndex]; // red + *rgbRowIndex++ = cmap[colorIndex + 1]; // green + *rgbRowIndex++ = cmap[colorIndex + 2]; // blue #endif + } else { + *rgbRowIndex++ = 0; // red + *rgbRowIndex++ = 0; // green + *rgbRowIndex++ = 0; // blue + } ++rowBufIndex; } for (int i=0; imAlphaLine, 0, abpr); for (PRUint32 x = 0; x < (PRUint32)width; ++x) { if (*rowBufIndex != decoder->mGIFStruct->tpixel) { - PRUint32 colorIndex = (*rowBufIndex < cmapsize) ? (*rowBufIndex * 3) : 0; -#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON) - *rgbRowIndex++ = cmap[colorIndex + 2]; // blue - *rgbRowIndex++ = cmap[colorIndex + 1]; // green - *rgbRowIndex++ = cmap[colorIndex]; // red -#else #if defined(XP_MAC) || defined(XP_MACOSX) *rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad #endif - *rgbRowIndex++ = cmap[colorIndex]; // red - *rgbRowIndex++ = cmap[colorIndex + 1]; // green - *rgbRowIndex++ = cmap[colorIndex + 2]; // blue + if (*rowBufIndex < cmapsize) { + PRUint32 colorIndex = *rowBufIndex * 3; +#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON) + *rgbRowIndex++ = cmap[colorIndex + 2]; // blue + *rgbRowIndex++ = cmap[colorIndex + 1]; // green + *rgbRowIndex++ = cmap[colorIndex]; // red +#else + *rgbRowIndex++ = cmap[colorIndex]; // red + *rgbRowIndex++ = cmap[colorIndex + 1]; // green + *rgbRowIndex++ = cmap[colorIndex + 2]; // blue #endif + } else { + *rgbRowIndex++ = 0; // red + *rgbRowIndex++ = 0; // green + *rgbRowIndex++ = 0; // blue + } decoder->mAlphaLine[x>>3] |= 1<<(7-x&0x7); } else { #if defined(XP_MAC) || defined(XP_MACOSX)