Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 1495113004: (Reland)WebGL 2: validate uniform block index (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
index d92a66c0d01553210f24831c756c331b6a5b6c95..24d330161a2a3d01799c5982cef2ad68aaf85e06 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -2316,11 +2316,25 @@ GLuint WebGL2RenderingContextBase::getUniformBlockIndex(WebGLProgram* program, c
return webContext()->getUniformBlockIndex(objectOrZero(program), uniformBlockName.utf8().data());
}
+bool WebGL2RenderingContextBase::validateUniformBlockIndex(const char* functionName, WebGLProgram* program, GLuint blockIndex)
+{
+ GLint activeUniformBlocks = 0;
+ webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCKS, &activeUniformBlocks);
+ if (blockIndex >= static_cast<GLuint>(activeUniformBlocks)) {
+ synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid uniform block index");
Zhenyao Mo 2015/12/04 20:17:10 Shouldn't this be an INVALID_VALUE instead? It's n
Ken Russell (switch to Gerrit) 2015/12/04 22:49:25 Yes, it should be INVALID_VALUE: "If uniformBlock
yunchao 2015/12/04 23:39:43 Yeah. This is a little wired. But I would like to
Ken Russell (switch to Gerrit) 2015/12/04 23:46:03 The spec says to generate an INVALID_VALUE error,
yunchao 2015/12/04 23:56:54 Done.
+ return false;
+ }
+ return true;
+}
+
ScriptValue WebGL2RenderingContextBase::getActiveUniformBlockParameter(ScriptState* scriptState, WebGLProgram* program, GLuint uniformBlockIndex, GLenum pname)
{
if (isContextLost() || !validateWebGLObject("getActiveUniformBlockParameter", program))
return ScriptValue::createNull(scriptState);
+ if (!validateUniformBlockIndex("getActiveUniformBlockParameter", program, uniformBlockIndex))
+ return ScriptValue::createNull(scriptState);
+
switch (pname) {
case GL_UNIFORM_BLOCK_BINDING:
case GL_UNIFORM_BLOCK_DATA_SIZE:
@@ -2357,6 +2371,9 @@ String WebGL2RenderingContextBase::getActiveUniformBlockName(WebGLProgram* progr
if (isContextLost() || !validateWebGLObject("getActiveUniformBlockName", program))
return String();
+ if (!validateUniformBlockIndex("getActiveUniformBlockParameter", program, uniformBlockIndex))
+ return String();
+
GLint maxNameLength = -1;
webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &maxNameLength);
if (maxNameLength <= 0) {
@@ -2375,6 +2392,9 @@ void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLui
if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program))
return;
+ if (!validateUniformBlockIndex("getActiveUniformBlockParameter", program, uniformBlockIndex))
Ken Russell (switch to Gerrit) 2015/12/04 22:49:25 getActiveUniformBlockParameter -> uniformBlockBind
yunchao 2015/12/04 23:39:43 Done.
+ return;
+
webContext()->uniformBlockBinding(objectOrZero(program), uniformBlockIndex, uniformBlockBinding);
}
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698