Bug 685471 - In PNG decoder, the allocating of mHeaderBuf can be prevented. (followup) r=joe@drew.ca
authorAlfred Kayser <alfredkayser@gmail.com>
Sat, 04 May 2013 13:42:26 +0200
changeset 130833 04abf5e608f1822a17638a3603b2f685d2352fb3
parent 130832 a546ce4ccb14ac4117bf3492f54cf6d55aa43f44
child 130834 e1fac3f4bd838dc3300360492e7a06fb703229c2
push id27558
push useralfredkayser@gmail.com
push dateSat, 04 May 2013 11:42:42 +0000
treeherdermozilla-inbound@04abf5e608f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs685471
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 685471 - In PNG decoder, the allocating of mHeaderBuf can be prevented. (followup) r=joe@drew.ca
image/decoders/nsPNGDecoder.cpp
image/decoders/nsPNGDecoder.h
--- a/image/decoders/nsPNGDecoder.cpp
+++ b/image/decoders/nsPNGDecoder.cpp
@@ -282,17 +282,17 @@ nsPNGDecoder::WriteInternal(const char *
   // If we only want width/height, we don't need to go through libpng
   if (IsSizeDecode()) {
 
     // Are we done?
     if (mHeaderBytesRead == BYTES_NEEDED_FOR_DIMENSIONS)
       return;
 
     // Scan the header for the width and height bytes
-    PRUint32 pos = 0;
+    uint32_t pos = 0;
     const uint8_t *bptr = (uint8_t *)aBuffer;
 
     while (pos < aCount && mHeaderBytesRead < BYTES_NEEDED_FOR_DIMENSIONS) {
       // Verify the signature bytes
       if (mHeaderBytesRead < sizeof(pngSignatureBytes)) {
         if (bptr[pos] != nsPNGDecoder::pngSignatureBytes[mHeaderBytesRead]) {
           PostDataError();
           return;
@@ -307,18 +307,18 @@ nsPNGDecoder::WriteInternal(const char *
       pos ++;
       mHeaderBytesRead ++;
     }
 
     // If we're done now, verify the data and set up the container
     if (mHeaderBytesRead == BYTES_NEEDED_FOR_DIMENSIONS) {
 
       // Grab the width and height, accounting for endianness (thanks libpng!)
-      PRUint32 width = png_get_uint_32(mSizeBytes);
-      PRUint32 height = png_get_uint_32(mSizeBytes + 4);
+      uint32_t width = png_get_uint_32(mSizeBytes);
+      uint32_t height = png_get_uint_32(mSizeBytes + 4);
 
       // Too big?
       if ((width > MOZ_PNG_MAX_DIMENSION) || (height > MOZ_PNG_MAX_DIMENSION)) {
         PostDataError();
         return;
       }
 
       // Post our size to the superclass
--- a/image/decoders/nsPNGDecoder.h
+++ b/image/decoders/nsPNGDecoder.h
@@ -74,18 +74,18 @@ public:
   uint8_t *mCMSLine;
   uint8_t *interlacebuf;
   qcms_profile *mInProfile;
   qcms_transform *mTransform;
 
   gfxASurface::gfxImageFormat format;
 
   // For size decodes
-  PRUint8  mSizeBytes[8]; // Space for width and height, both 4 bytes
-  PRUint32 mHeaderBytesRead;
+  uint8_t mSizeBytes[8]; // Space for width and height, both 4 bytes
+  uint32_t mHeaderBytesRead;
 
   // whether CMS or premultiplied alpha are forced off
   uint32_t mCMSMode;
 
   uint8_t mChannels;
   bool mFrameHasNoAlpha;
   bool mFrameIsHidden;
   bool mDisablePremultipliedAlpha;