Bug 539356 - Part 23 - Fix MovePixels crash when our surface is in an error state. r=jrmuizel

This commit is contained in:
Matt Woodrow 2012-07-23 15:00:37 +12:00
parent 35775825fa
commit b2fd923dac

View File

@ -488,6 +488,13 @@ gfxASurface::MovePixels(const nsIntRect& aSourceRect,
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));