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 14:10:21 -0400
changeset 26419 58003e3413ca492aa7eaf2fc6c9c84448babe153
parent 26418 43e8eb5ccab2ca91cada06e9e18cef35bacd9dae
child 26420 14cd5d57b6397bcd62ef75973f3fafe49526f81c
push id2008
push userjdrew@mozilla.com
push dateTue, 22 Sep 2009 18:21:16 +0000
reviewersjrmuizel, alfredkeyser, vlad
bugs511689
milestone1.9.1.4pre
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
@@ -409,19 +409,24 @@ 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.
     mImageFrame->SetTimeout(mGIFStruct.delay_time);
     if (mGIFStruct.images_decoded)
       mImageContainer->AppendFrame(mImageFrame);
     mImageContainer->EndFrameDecode(mGIFStruct.images_decoded, mGIFStruct.delay_time);
-    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, mImageFrame);
 
   // Release reference to this frame
   mImageFrame = nsnull;
 
   // Reset the transparent pixel
   if (mOldColor) {