Bug 539356 - Part 23 - Fix MovePixels crash when our surface is in an error state. r=jrmuizel
authorMatt Woodrow <mwoodrow@mozilla.com>
Sat, 30 Jun 2012 15:06:13 +1200
changeset 98025 3f8e99e9234442b96484b5fe66d9d39e57c63a20
parent 98024 ba7021170544272ea019fce1323e3475b70a85ff
child 98026 6e8c5c011767c7d7e5072dc27cb192750ce347c0
push id23017
push userryanvm@gmail.com
push dateSat, 30 Jun 2012 19:29:24 +0000
treeherdermozilla-central@4c2ddc60f360 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs539356
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 539356 - Part 23 - Fix MovePixels crash when our surface is in an error state. r=jrmuizel
gfx/thebes/gfxASurface.cpp
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -483,16 +483,23 @@ void
 gfxASurface::MovePixels(const nsIntRect& aSourceRect,
                         const nsIntPoint& aDestTopLeft)
 {
     // Assume the backend can't handle self copying well and allocate
     // a temporary surface instead.
     nsRefPtr<gfxASurface> tmp = 
       CreateSimilarSurface(GetContentType(), 
                            gfxIntSize(aSourceRect.width, aSourceRect.height));
+    // CreateSimilarSurface can return nsnull if the current surface is
+    // in an error state. This isn't good, but its better to carry
+    // on with the error surface instead of crashing.
+    NS_ASSERTION(tmp, "Must have temporary surface to move pixels!");
+    if (!tmp) {
+        return;
+    }
     nsRefPtr<gfxContext> ctx = new gfxContext(tmp);
     ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
     ctx->SetSource(this, gfxPoint(-aSourceRect.x, -aSourceRect.y));
     ctx->Paint();
 
     ctx = new gfxContext(this);
     ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
     ctx->SetSource(tmp, gfxPoint(aDestTopLeft.x, aDestTopLeft.y));