summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniform_query.cpp
diff options
context:
space:
mode:
authorTapani Pälli <tapani.palli@intel.com>2014-09-12 10:36:08 +0300
committerTapani Pälli <tapani.palli@intel.com>2014-09-15 07:33:12 +0300
commit9bd139e4515172d98e91d6ed7364ec3ea5cf623d (patch)
tree1b627a699d051f13cbdd4f17947cc22bb38fc024 /src/mesa/main/uniform_query.cpp
parentce50a61d3659582d18957b4c953904ad92c417ec (diff)
downloadexternal_mesa3d-9bd139e4515172d98e91d6ed7364ec3ea5cf623d.zip
external_mesa3d-9bd139e4515172d98e91d6ed7364ec3ea5cf623d.tar.gz
external_mesa3d-9bd139e4515172d98e91d6ed7364ec3ea5cf623d.tar.bz2
mesa: check that uniform exists in glUniform* functions
Remap table for uniforms may contain empty entries when using explicit uniform locations. If no active/inactive variable exists with given location, remap table contains NULL. v2: move remap table bounds check before existence check (Ian Romanick) Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Tested-by: Erik Faye-Lund <kusmabite@gmail.com> (v1) Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83574
Diffstat (limited to 'src/mesa/main/uniform_query.cpp')
-rw-r--r--src/mesa/main/uniform_query.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 4cd2bca..1592c9b 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -226,6 +226,13 @@ validate_uniform_parameters(struct gl_context *ctx,
return NULL;
}
+ /* Check that the given location is in bounds of uniform remap table. */
+ if (location >= (GLint) shProg->NumUniformRemapTable) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
+ caller, location);
+ return NULL;
+ }
+
/* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says:
*
* "If any of the following conditions occur, an INVALID_OPERATION
@@ -239,19 +246,12 @@ validate_uniform_parameters(struct gl_context *ctx,
* - if count is greater than one, and the uniform declared in the
* shader is not an array variable,
*/
- if (location < -1) {
+ if (location < -1 || !shProg->UniformRemapTable[location]) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
caller, location);
return NULL;
}
- /* Check that the given location is in bounds of uniform remap table. */
- if (location >= (GLint) shProg->NumUniformRemapTable) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
- caller, location);
- return NULL;
- }
-
/* If the driver storage pointer in remap table is -1, we ignore silently.
*
* GL_ARB_explicit_uniform_location spec says: