Bug 1466001 - Index buffer must be non-null. - r=kvark draft
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 29 Mar 2018 17:28:56 -0700
changeset 802534 51532156a495657e6c1d7bc836ff555c862161e6
parent 802478 c7e3b733ca714fae74515bac3d27da4cdc049f13
push id111901
push userbmo:jgilbert@mozilla.com
push dateFri, 01 Jun 2018 00:35:13 +0000
reviewerskvark
bugs1466001
milestone62.0a1
Bug 1466001 - Index buffer must be non-null. - r=kvark MozReview-Commit-ID: ConbNwht4Pp
dom/canvas/WebGLContextDraw.cpp
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -656,28 +656,29 @@ WebGLContext::DrawElements_check(const c
             gl->fEnable(LOCAL_GL_PRIMITIVE_RESTART);
             gl->fPrimitiveRestartIndex(ones);
         }
     }
 
     ////
     // Index fetching
 
+    const auto& indexBuffer = mBoundVertexArray->mElementArrayBuffer;
+    if (!indexBuffer) {
+        ErrorInvalidOperation("%s: Index buffer not bound.", funcName);
+        return false;
+    }
+    MOZ_ASSERT(!indexBuffer->IsBoundForTF(), "This should be impossible.");
+
     if (!indexCount || !instanceCount) {
         *out_lastVert = Nothing();
         return true;
     }
 
-    const auto& indexBuffer = mBoundVertexArray->mElementArrayBuffer;
-
-    size_t availBytes = 0;
-    if (indexBuffer) {
-        MOZ_ASSERT(!indexBuffer->IsBoundForTF(), "This should be impossible.");
-        availBytes = indexBuffer->ByteLength();
-    }
+    const size_t availBytes = indexBuffer->ByteLength();
     const auto availIndices = AvailGroups(availBytes, byteOffset, bytesPerIndex,
                                           bytesPerIndex);
     if (indexCount > availIndices) {
         ErrorInvalidOperation("%s: Index buffer too small.", funcName);
         return false;
     }
 
     *out_lastVert = indexBuffer->GetIndexedFetchMaxVert(type, byteOffset, indexCount);