Bug 682677 - Eliminated direct access to mInfo->pixel_depth, which is not allowed in libpng15. We access pixel_depth via png_get_IHDR() instead; r=joedrew

This commit is contained in:
Glenn Randers-Pehrson 2011-11-05 10:48:26 +00:00
parent fb722a61dd
commit e35ed10ff2
2 changed files with 17 additions and 12 deletions

View File

@ -386,8 +386,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
// Raymond Chen says that 32bpp only are valid PNG ICOs
// http://blogs.msdn.com/b/oldnewthing/archive/2010/10/22/10079192.aspx
if (static_cast<nsPNGDecoder*>(mContainedDecoder.get())->HasValidInfo() &&
static_cast<nsPNGDecoder*>(mContainedDecoder.get())->GetPixelDepth() != 32) {
if (!static_cast<nsPNGDecoder*>(mContainedDecoder.get())->IsValidICO()) {
PostDataError();
}
return;

View File

@ -73,19 +73,25 @@ public:
void EndImageFrame();
// Checks if the info header contains valid information
bool HasValidInfo() const
// Check if PNG is valid ICO (32bpp RGBA)
// http://blogs.msdn.com/b/oldnewthing/archive/2010/10/22/10079192.aspx
bool IsValidICO() const
{
return mInfo && mInfo->valid;
}
png_uint_32
png_width, // Unused
png_height; // Unused
// Obtain the pixel depth if available or 0 otherwise
PRInt32 GetPixelDepth() const
{
if (!mInfo) {
return 0;
int png_bit_depth,
png_color_type;
if (png_get_IHDR(mPNG, mInfo, &png_width, &png_height, &png_bit_depth,
&png_color_type, NULL, NULL, NULL)) {
return (png_color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
png_bit_depth == 8);
} else {
return false;
}
return mInfo->pixel_depth;
}
public: