Bug 1136494 - Validate mActiveProgramLinkInfo in ScopedResolveTexturesForDraw, since it's run first. - r=mtseng
MozReview-Commit-ID: Dq8C5OnwjRM
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -89,16 +89,22 @@ WebGLTexture::IsFeedback(WebGLContext* w
ScopedResolveTexturesForDraw::ScopedResolveTexturesForDraw(WebGLContext* webgl,
const char* funcName,
bool* const out_error)
: mWebGL(webgl)
{
MOZ_ASSERT(mWebGL->gl->IsCurrent());
+ if (!mWebGL->mActiveProgramLinkInfo) {
+ mWebGL->ErrorInvalidOperation("%s: The current program is not linked.", funcName);
+ *out_error = true;
+ return;
+ }
+
std::vector<const WebGLFBAttachPoint*> fbAttachments;
if (mWebGL->mBoundDrawFramebuffer) {
const auto& fb = mWebGL->mBoundDrawFramebuffer;
fb->GatherAttachments(&fbAttachments);
}
MOZ_ASSERT(mWebGL->mActiveProgramLinkInfo);
const auto& uniformSamplers = mWebGL->mActiveProgramLinkInfo->uniformSamplers;
@@ -241,22 +247,16 @@ WebGLContext::DrawArrays_check(GLint fir
return false;
}
// If count is 0, there's nothing to do.
if (count == 0 || primcount == 0) {
return false;
}
- // Any checks below this depend on a program being available.
- if (!mCurrentProgram) {
- ErrorInvalidOperation("%s: null CURRENT_PROGRAM", info);
- return false;
- }
-
if (!ValidateBufferFetching(info)) {
return false;
}
CheckedInt<GLsizei> checked_firstPlusCount = CheckedInt<GLsizei>(first) + count;
if (!checked_firstPlusCount.isValid()) {
ErrorInvalidOperation("%s: overflow in first+count", info);
@@ -406,24 +406,16 @@ WebGLContext::DrawElements_check(GLsizei
const GLsizei first = byteOffset / bytesPerElem;
const CheckedUint32 checked_byteCount = bytesPerElem * CheckedUint32(count);
if (!checked_byteCount.isValid()) {
ErrorInvalidValue("%s: overflow in byteCount", info);
return false;
}
- // Any checks below this depend on mActiveProgramLinkInfo being available.
- if (!mActiveProgramLinkInfo) {
- // Technically, this will only be null iff CURRENT_PROGRAM is null.
- // But it's better to branch on what we actually care about.
- ErrorInvalidOperation("%s: null CURRENT_PROGRAM", info);
- return false;
- }
-
if (!mBoundVertexArray->mElementArrayBuffer) {
ErrorInvalidOperation("%s: must have element array buffer binding", info);
return false;
}
WebGLBuffer& elemArrayBuffer = *mBoundVertexArray->mElementArrayBuffer;
if (!elemArrayBuffer.ByteLength()) {