Bug 685471 - In PNG decoder, the allocating of mHeaderBuf can be prevented. (followup) r=joe@drew.ca

This commit is contained in:
Alfred Kayser 2013-05-04 13:42:26 +02:00
parent e0c75c54ed
commit f6f5713fa6
2 changed files with 5 additions and 5 deletions

View File

@ -287,7 +287,7 @@ nsPNGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
return; return;
// Scan the header for the width and height bytes // Scan the header for the width and height bytes
PRUint32 pos = 0; uint32_t pos = 0;
const uint8_t *bptr = (uint8_t *)aBuffer; const uint8_t *bptr = (uint8_t *)aBuffer;
while (pos < aCount && mHeaderBytesRead < BYTES_NEEDED_FOR_DIMENSIONS) { while (pos < aCount && mHeaderBytesRead < BYTES_NEEDED_FOR_DIMENSIONS) {
@ -312,8 +312,8 @@ nsPNGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
if (mHeaderBytesRead == BYTES_NEEDED_FOR_DIMENSIONS) { if (mHeaderBytesRead == BYTES_NEEDED_FOR_DIMENSIONS) {
// Grab the width and height, accounting for endianness (thanks libpng!) // Grab the width and height, accounting for endianness (thanks libpng!)
PRUint32 width = png_get_uint_32(mSizeBytes); uint32_t width = png_get_uint_32(mSizeBytes);
PRUint32 height = png_get_uint_32(mSizeBytes + 4); uint32_t height = png_get_uint_32(mSizeBytes + 4);
// Too big? // Too big?
if ((width > MOZ_PNG_MAX_DIMENSION) || (height > MOZ_PNG_MAX_DIMENSION)) { if ((width > MOZ_PNG_MAX_DIMENSION) || (height > MOZ_PNG_MAX_DIMENSION)) {

View File

@ -79,8 +79,8 @@ public:
gfxASurface::gfxImageFormat format; gfxASurface::gfxImageFormat format;
// For size decodes // For size decodes
PRUint8 mSizeBytes[8]; // Space for width and height, both 4 bytes uint8_t mSizeBytes[8]; // Space for width and height, both 4 bytes
PRUint32 mHeaderBytesRead; uint32_t mHeaderBytesRead;
// whether CMS or premultiplied alpha are forced off // whether CMS or premultiplied alpha are forced off
uint32_t mCMSMode; uint32_t mCMSMode;