Bug 511689 - Ensure we're always on the correct frame when decoding GIF images. r=jrmuizel,alfredkeyser sr=vlad
authorJoe Drew <joe@drew.ca>
Tue, 22 Sep 2009 15:33:33 -0400
changeset 31863 3bc177bd871f6da74796d5996c187184a68e6be1
parent 31862 41b236f244fd4148de9ff85a70b58347b9820b2a
child 31864 10595ea485721161e944bcbcc625ab4f1be36ada
push id216
push userjdrew@mozilla.com
push dateTue, 22 Sep 2009 19:37:32 +0000
reviewersjrmuizel, alfredkeyser, vlad
bugs511689
milestone1.9.2b1pre
Bug 511689 - Ensure we're always on the correct frame when decoding GIF images. r=jrmuizel,alfredkeyser sr=vlad
modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp
--- a/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp
+++ b/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp
@@ -415,19 +415,23 @@ void nsGIFDecoder2::EndImageFrame()
     }
 
     // We actually have the timeout information before we get the lzw encoded 
     // image data, at least according to the spec, but we delay in setting the 
     // timeout for the image until here to help ensure that we have the whole 
     // image frame decoded before we go off and try to display another frame.
     mImageContainer->SetFrameTimeout(mGIFStruct.images_decoded, mGIFStruct.delay_time);
     mImageContainer->EndFrameDecode(mGIFStruct.images_decoded);
+  }
 
-    mGIFStruct.images_decoded++;
-  }
+  // Unconditionally increment images_decoded, because we unconditionally
+  // append frames in BeginImageFrame(). This ensures that images_decoded
+  // always refers to the frame in mImageContainer we're currently decoding,
+  // even if some of them weren't decoded properly and thus are blank.
+  mGIFStruct.images_decoded++;
 
   if (mObserver)
     mObserver->OnStopFrame(nsnull, curframe);
 
   // Reset the transparent pixel
   if (mOldColor) {
     mColormap[mGIFStruct.tpixel] = mOldColor;
     mOldColor = 0;