Bug 1443149 - Ensure WebGLFBAttachPoint::HasImage() before dereferencing Format(). r?jgilbert draft
authorJamie Nicol <jnicol@mozilla.com>
Wed, 14 Mar 2018 16:42:37 +0000
changeset 767450 1d684e839942598f6cba00cec755e058c12e0839
parent 767347 80b4777a6421d8df4bb27ac23fb607c318a3006c
push id102602
push userbmo:jnicol@mozilla.com
push dateWed, 14 Mar 2018 16:48:54 +0000
reviewersjgilbert
bugs1443149
milestone61.0a1
Bug 1443149 - Ensure WebGLFBAttachPoint::HasImage() before dereferencing Format(). r?jgilbert Previously we were checking IsDefined() rather than HasImage(), but were hitting crashes. This was because Format() can return null if the attach point is defined but the attached texture level or renderbuffer aren't themselves defined. HasImage() checks for this case. MozReview-Commit-ID: 8KY3zPXXAFv
dom/canvas/WebGLContextFramebufferOperations.cpp
--- a/dom/canvas/WebGLContextFramebufferOperations.cpp
+++ b/dom/canvas/WebGLContextFramebufferOperations.cpp
@@ -28,17 +28,17 @@ WebGLContext::Clear(GLbitfield mask)
         GenerateWarning("Calling gl.clear(0) has no effect.");
     } else if (mRasterizerDiscardEnabled) {
         GenerateWarning("Calling gl.clear() with RASTERIZER_DISCARD enabled has no effects.");
     }
 
     if (mask & LOCAL_GL_COLOR_BUFFER_BIT && mBoundDrawFramebuffer) {
         if (mask & LOCAL_GL_COLOR_BUFFER_BIT) {
             for (const auto& cur : mBoundDrawFramebuffer->ColorDrawBuffers()) {
-                if (!cur->IsDefined())
+                if (!cur->HasImage())
                     continue;
 
                 switch (cur->Format()->format->componentType) {
                 case webgl::ComponentType::Float:
                 case webgl::ComponentType::NormInt:
                 case webgl::ComponentType::NormUInt:
                     break;