Bug 1313884 - Check if mTarget is null in CanvasRenderingContext2D::DrawImage
authorRyan Hunt <rhunt@eqrion.net>
Tue, 01 Nov 2016 13:56:55 -0500
changeset 432793 c7ae634cfdf2d493085bbb6d7c552dff03856270
parent 432792 aa39c1a962ffa63c1c5017b8c824663dea930771
child 432794 f43b6c8e32da3ffbdd2b3d1b383c940f16296a26
child 433097 623739146f226f7330902c89df889132969f1da9
push id34424
push userbmo:jmaher@mozilla.com
push dateWed, 02 Nov 2016 19:59:36 +0000
bugs1313884
milestone52.0a1
Bug 1313884 - Check if mTarget is null in CanvasRenderingContext2D::DrawImage
dom/canvas/CanvasRenderingContext2D.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -4938,16 +4938,21 @@ CanvasRenderingContext2D::DrawImage(cons
 
   gfx::Rect bounds;
 
   if (NeedToCalculateBounds()) {
     bounds = gfx::Rect(aDx, aDy, aDw, aDh);
     bounds = mTarget->GetTransform().TransformBounds(bounds);
   }
 
+  if (!IsTargetValid()) {
+    gfxCriticalError() << "Unexpected invalid target in a Canvas2d.";
+    return;
+  }
+
   if (srcSurf) {
     gfx::Rect sourceRect(aSx, aSy, aSw, aSh);
     if (element == mCanvasElement) {
       // srcSurf is a snapshot of mTarget. If we draw to mTarget now, we'll
       // trigger a COW copy of the whole canvas into srcSurf. That's a huge
       // waste if sourceRect doesn't cover the whole canvas.
       // We avoid copying the whole canvas by manually copying just the part
       // that we need.