Bug 1466001 - Index buffer must be non-null. - r=kvark
MozReview-Commit-ID: ConbNwht4Pp
--- 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);