Bug 878392 - Reset Decoder::mCurrentFrame to nullptr if we fail to create a frame. r=seth a=bajaj
authorJoe Drew <joe@drew.ca>
Fri, 07 Jun 2013 16:42:57 -0400
changeset 142859 8c00358026609dbd207142471291da1b3862b2c0
parent 142858 58bef88a459c30fe6972be32ff88d201607d6a99
child 142860 729b0fcda14de123ab6a60240b8cdc446863fe99
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth, bajaj
bugs878392
milestone23.0a2
Bug 878392 - Reset Decoder::mCurrentFrame to nullptr if we fail to create a frame. r=seth a=bajaj
image/src/Decoder.cpp
--- a/image/src/Decoder.cpp
+++ b/image/src/Decoder.cpp
@@ -194,30 +194,38 @@ nsresult
 Decoder::AllocateFrame()
 {
   MOZ_ASSERT(mNeedsNewFrame);
   MOZ_ASSERT(NS_IsMainThread());
 
   MarkFrameDirty();
 
   nsresult rv;
+  imgFrame* frame = nullptr;
   if (mNewFrameData.mPaletteDepth) {
     rv = mImage.EnsureFrame(mNewFrameData.mFrameNum, mNewFrameData.mOffsetX,
                             mNewFrameData.mOffsetY, mNewFrameData.mWidth,
                             mNewFrameData.mHeight, mNewFrameData.mFormat,
                             mNewFrameData.mPaletteDepth,
                             &mImageData, &mImageDataLength,
-                            &mColormap, &mColormapSize, &mCurrentFrame);
+                            &mColormap, &mColormapSize, &frame);
   } else {
     rv = mImage.EnsureFrame(mNewFrameData.mFrameNum, mNewFrameData.mOffsetX,
                             mNewFrameData.mOffsetY, mNewFrameData.mWidth,
                             mNewFrameData.mHeight, mNewFrameData.mFormat,
-                            &mImageData, &mImageDataLength, &mCurrentFrame);
+                            &mImageData, &mImageDataLength, &frame);
   }
 
+  if (NS_SUCCEEDED(rv)) {
+    mCurrentFrame = frame;
+  } else {
+    mCurrentFrame = nullptr;
+  }
+
+  // Notify if appropriate
   if (NS_SUCCEEDED(rv) && mNewFrameData.mFrameNum == mFrameCount) {
     PostFrameStart();
   } else if (NS_FAILED(rv)) {
     PostDataError();
   }
 
   // Mark ourselves as not needing another frame before talking to anyone else
   // so they can tell us if they need yet another.