Bug 1313884 - Part 2: Additional nullptr test and nightly/aurora crash if bad things happen. r=gw280
☠☠ backed out by 056085427582 ☠ ☠
authorMilan Sreckovic <milan@mozilla.com>
Thu, 10 Nov 2016 10:26:00 -0500
changeset 348821 bb4879b87c176f4d644cab920f41e7c430e7c484
parent 348820 ca77916dbaef9b01126a96d8c222a3942a8e4cdf
child 348822 13ed22321146fa7779394fc20ddee89de631b5d1
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw280
bugs1313884
milestone52.0a1
Bug 1313884 - Part 2: Additional nullptr test and nightly/aurora crash if bad things happen. r=gw280
dom/canvas/CanvasRenderingContext2D.cpp
gfx/2d/Logging.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -4971,18 +4971,22 @@ CanvasRenderingContext2D::DrawImage(cons
     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.
       srcSurf = ExtractSubrect(srcSurf, &sourceRect, mTarget);
     }
-    AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
-      DrawSurface(srcSurf,
+    DrawTarget* adt = AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds);
+    if (!adt) {
+      gfxDevCrash(LogReason::InvalidDrawTarget) << "Invalid adjusted target in Canvas2D " << gfx::hexa(mTarget) << "< " << NeedToDrawShadow() << NeedToApplyFilter();
+      return;
+    }
+    adt->DrawSurface(srcSurf,
                   gfx::Rect(aDx, aDy, aDw, aDh),
                   sourceRect,
                   DrawSurfaceOptions(samplingFilter, SamplingBounds::UNBOUNDED),
                   DrawOptions(CurrentState().globalAlpha, UsedOperation(), antialiasMode));
   } else {
     DrawDirectlyToCanvas(drawInfo, &bounds,
                          gfx::Rect(aDx, aDy, aDw, aDh),
                          gfx::Rect(aSx, aSy, aSw, aSh),
--- a/gfx/2d/Logging.h
+++ b/gfx/2d/Logging.h
@@ -124,16 +124,17 @@ enum class LogReason : int {
   InvalidContext,
   InvalidCommandList,
   AsyncTransactionTimeout, // 30
   TextureCreation,
   InvalidCacheSurface,
   AlphaWithBasicClient,
   UnbalancedClipStack,
   ProcessingError,
+  InvalidDrawTarget,
   // End
   MustBeLessThanThis = 101,
 };
 
 struct BasicLogger
 {
   // For efficiency, this method exists and copies the logic of the
   // OutputMessage below.  If making any changes here, also make it