Bug 1319668 - Check for null context before trying to draw canvas text. r=mats
authorJonathan Kew <jkew@mozilla.com>
Sat, 03 Dec 2016 14:49:46 +0000
changeset 325219 5144592dd9180a21472159e4d813a7f61c90484e
parent 325218 71fff6495d23e355d5147d9673dfd5df30d3953c
child 325220 6bdef7ba8b4108a996b9f61ef9f81c5ea6c93017
child 325244 bd4568a3fd8bad6ff4d8797175209a61462cdca0
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmats
bugs1319668
milestone53.0a1
Bug 1319668 - Check for null context before trying to draw canvas text. r=mats
dom/canvas/CanvasRenderingContext2D.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -4054,16 +4054,21 @@ struct MOZ_STACK_CLASS CanvasBidiProcess
     StrokeOptions strokeOpts;
     DrawOptions drawOpts;
     Style style = (mOp == CanvasRenderingContext2D::TextDrawOperation::FILL)
                     ? Style::FILL
                     : Style::STROKE;
     AdjustedTarget target(mCtx);
     RefPtr<gfxContext> thebes =
       gfxContext::CreatePreservingTransformOrNull(target);
+    if (!thebes) {
+      // If CreatePreservingTransformOrNull returns null, it will also have
+      // issued a gfxCriticalNote already, so here we'll just bail out.
+      return;
+    }
     gfxTextRun::DrawParams params(thebes);
 
     if (mState->StyleIsColor(style)) { // Color
       nscolor fontColor = mState->colorStyles[style];
       if (style == Style::FILL) {
         params.context->SetColor(Color::FromABGR(fontColor));
       } else {
         params.textStrokeColor = fontColor;