Bug 1276413 (Part 1) - Clear paletted image frames when they're allocated. r=edwin
authorSeth Fowler <mark.seth.fowler@gmail.com>
Wed, 01 Jun 2016 11:59:47 -0700
changeset 338993 817695430906243ef1f46f3c8df49f2b86f489ef
parent 338992 2a0eda9a4bb60ed7c318a4d45247f5fe78de2256
child 338994 9cef1a1fa8a2d158bcd53c946462dbb62f871ee9
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1276413
milestone49.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 1276413 (Part 1) - Clear paletted image frames when they're allocated. r=edwin
image/imgFrame.cpp
--- a/image/imgFrame.cpp
+++ b/image/imgFrame.cpp
@@ -198,20 +198,20 @@ imgFrame::InitForDecoder(const nsIntSize
       NS_WARNING("Should have legal palette depth");
       NS_ERROR("This Depth is not supported");
       mAborted = true;
       return NS_ERROR_FAILURE;
     }
 
     // Use the fallible allocator here. Paletted images always use 1 byte per
     // pixel, so calculating the amount of memory we need is straightforward.
-    mPalettedImageData =
-      static_cast<uint8_t*>(malloc(PaletteDataLength() + mFrameRect.Area()));
+    size_t dataSize = PaletteDataLength() + mFrameRect.Area();
+    mPalettedImageData = static_cast<uint8_t*>(calloc(dataSize, sizeof(uint8_t)));
     if (!mPalettedImageData) {
-      NS_WARNING("malloc for paletted image data should succeed");
+      NS_WARNING("Call to calloc for paletted image data should succeed");
     }
     NS_ENSURE_TRUE(mPalettedImageData, NS_ERROR_OUT_OF_MEMORY);
   } else {
     MOZ_ASSERT(!mImageSurface, "Called imgFrame::InitForDecoder() twice?");
 
     mVBuf = AllocateBufferForImage(mFrameRect.Size(), mFormat);
     if (!mVBuf) {
       mAborted = true;