Bug 1303301 - Add nullptr handling. r=mtseng, a=ritu
authorSotaro Ikeda <sotaro.ikeda.g@gmail.com>
Fri, 30 Sep 2016 00:29:34 -0700
changeset 428770 372cbe11c92e40200fb25244a9947990ef7093ed
parent 428769 d1699ef21941da9667d6c92236710291652b7199
child 428771 3576ed3ba47a14f5ce5b8329619a0f2b24ece66b
push id33416
push userpaul@paul.cx
push dateMon, 24 Oct 2016 16:26:20 +0000
reviewersmtseng, ritu
bugs1303301
milestone50.0
Bug 1303301 - Add nullptr handling. r=mtseng, a=ritu
dom/canvas/WebGLContext.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -817,18 +817,21 @@ WebGLContext::ResizeBackbuffer(uint32_t 
     }
     return true;
 }
 
 void
 WebGLContext::ThrowEvent_WebGLContextCreationError(const nsACString& text)
 {
     RefPtr<EventTarget> target = mCanvasElement;
-    if (!target) {
+    if (!target && mOffscreenCanvas) {
         target = mOffscreenCanvas;
+    } else if (!target) {
+        GenerateWarning("Failed to create WebGL context: %s", text.BeginReading());
+        return;
     }
 
     const auto kEventName = NS_LITERAL_STRING("webglcontextcreationerror");
 
     WebGLContextEventInit eventInit;
     // eventInit.mCancelable = true; // The spec says this, but it's silly.
     eventInit.mStatusMessage = NS_ConvertASCIItoUTF16(text);