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

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

Issue 1547783002: Reland of 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..9f192c103242e66b772cdba52d88ae38082faf43 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -2316,9 +2316,23 @@
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_VALUE, functionName, "invalid uniform block index");
+ 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) {
@@ -2357,6 +2371,9 @@
if (isContextLost() || !validateWebGLObject("getActiveUniformBlockName", program))
return String();
+ if (!validateUniformBlockIndex("getActiveUniformBlockName", program, uniformBlockIndex))
+ return String();
+
GLint maxNameLength = -1;
webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &maxNameLength);
if (maxNameLength <= 0) {
@@ -2373,6 +2390,9 @@
void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
{
if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program))
+ return;
+
+ if (!validateUniformBlockIndex("uniformBlockBinding", program, uniformBlockIndex))
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