Bug 1444506 - part 5 - don't attempt to draw an invalid video source in canvas. r=jrmuizel, a=jcristau
authorLee Salzman <lsalzman@mozilla.com>
Mon, 12 Mar 2018 16:37:10 -0400
changeset 462754 91ea59ff7425cdc67aa77a3a0b46aadba165f10d
parent 462753 18cc24b781fb4ca01031677d22fdff10c5e41e80
child 462755 0c7ea7d9aede9a18cecc52c563d93f4dae449cca
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, jcristau
bugs1444506
milestone60.0
Bug 1444506 - part 5 - don't attempt to draw an invalid video source in canvas. r=jrmuizel, a=jcristau
dom/canvas/CanvasRenderingContext2D.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -5278,16 +5278,19 @@ CanvasRenderingContext2D::DrawImage(cons
 
     imgSize = res.mSize;
 
     // Scale sw/sh based on aspect ratio
     if (aImage.IsHTMLVideoElement()) {
       HTMLVideoElement* video = &aImage.GetAsHTMLVideoElement();
       int32_t displayWidth = video->VideoWidth();
       int32_t displayHeight = video->VideoHeight();
+      if (displayWidth == 0 || displayHeight == 0) {
+        return;
+      }
       aSw *= (double)imgSize.width / (double)displayWidth;
       aSh *= (double)imgSize.height / (double)displayHeight;
     }
 
     if (mCanvasElement) {
       CanvasUtils::DoDrawImageSecurityCheck(mCanvasElement,
                                             res.mPrincipal, res.mIsWriteOnly,
                                             res.mCORSUsed);