Bug 570625, part -1: ThebesLayerBuffer::SetBuffer needs to hold its ref to the old buffer. r=roc
authorChris Jones <jones.chris.g@gmail.com>
Tue, 14 Sep 2010 00:23:08 -0500
changeset 54099 16b228558c58fd66ee3bfb95821f9fa92e204feb
parent 54098 74d032cc8e4fc03a19cb915c02cb3f72a02422d4
child 54100 324632361f18ce038234184757d878b5fe21f550
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs570625
milestone2.0b6pre
Bug 570625, part -1: ThebesLayerBuffer::SetBuffer needs to hold its ref to the old buffer. r=roc
gfx/layers/ThebesLayerBuffer.h
--- a/gfx/layers/ThebesLayerBuffer.h
+++ b/gfx/layers/ThebesLayerBuffer.h
@@ -155,21 +155,21 @@ protected:
 
   const nsIntRect& BufferRect() const { return mBufferRect; }
   const nsIntPoint& BufferRotation() const { return mBufferRotation; }
 
   already_AddRefed<gfxASurface>
   SetBuffer(gfxASurface* aBuffer,
             const nsIntRect& aBufferRect, const nsIntPoint& aBufferRotation)
   {
-    gfxASurface* tmp = mBuffer;
+    nsRefPtr<gfxASurface> tmp = mBuffer.forget();
     mBuffer = aBuffer;
     mBufferRect = aBufferRect;
     mBufferRotation = aBufferRotation;
-    return tmp;
+    return tmp.forget();
   }
 
 private:
   PRBool BufferSizeOkFor(const nsIntSize& aSize)
   {
     return (aSize == mBufferRect.Size() ||
             (SizedToVisibleBounds != mBufferSizePolicy &&
              aSize < mBufferRect.Size()));