Bug 802144 - Don't delete memory used for image frames while the decoder could still try to use it. r=joe
authorJosh Matthews <josh@joshmatthews.net>
Tue, 16 Oct 2012 22:45:14 -0400
changeset 110635 f8e8868022316daaebb834879d01f78061710894
parent 110634 16adea14324fcb0ee3f255cbec28e01565a39026
child 110636 7a8f277d19dfb6a98980f7698beb412a0078c6ae
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersjoe
bugs802144
milestone19.0a1
Bug 802144 - Don't delete memory used for image frames while the decoder could still try to use it. r=joe
image/src/RasterImage.cpp
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -247,22 +247,16 @@ RasterImage::RasterImage(imgStatusTracke
 
 }
 
 //******************************************************************************
 RasterImage::~RasterImage()
 {
   ScaleRequest::Stop(mScaleRequest.image);
 
-  delete mAnim;
-
-  for (unsigned int i = 0; i < mFrames.Length(); ++i)
-    delete mFrames[i];
-  mFrames.Clear();
-
   // Discardable statistics
   if (mDiscardable) {
     num_discardable_containers--;
     discardable_source_bytes -= mSourceData.Length();
 
     PR_LOG (gCompressedImageAccountingLog, PR_LOG_DEBUG,
             ("CompressedImageAccounting: destroying RasterImage %p.  "
              "Total Containers: %d, Discardable containers: %d, "
@@ -277,16 +271,21 @@ RasterImage::~RasterImage()
 
   // If we have a decoder open, shut it down
   if (mDecoder) {
     nsresult rv = ShutdownDecoder(eShutdownIntent_Interrupted);
     if (NS_FAILED(rv))
       NS_WARNING("Failed to shut down decoder in destructor!");
   }
 
+  delete mAnim;
+
+  for (unsigned int i = 0; i < mFrames.Length(); ++i)
+    delete mFrames[i];
+
   // Total statistics
   num_containers--;
   total_source_bytes -= mSourceData.Length();
 }
 
 void
 RasterImage::Initialize()
 {