summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniform_query.cpp
diff options
context:
space:
mode:
authorDylan Noblesmith <[email protected]>2011-12-22 21:05:38 +0000
committerDylan Noblesmith <[email protected]>2012-03-13 15:59:24 +0000
commitb536ac6b2bc54ad9bb6e58fbd307055e419a288f (patch)
tree292434c3285e774ceaf1eb89a47fd9a07b563e77 /src/mesa/main/uniform_query.cpp
parentcc5b0ffae048824a6bdcaf43e0c8c2dd4a7ff14b (diff)
mesa: add back glGetnUniform*v() overflow error reporting
The error was removed in: commit 719909698c67c287a393d2380278e7b7495ae018 Author: Ian Romanick <[email protected]> Date: Tue Oct 18 16:01:49 2011 -0700 mesa: Rewrite the way uniforms are tracked and handled The GL_ARB_robustness spec doesn't say the implementation should truncate the output, so just return after setting the required error like it did before the above commit. Also fixup an old comment and add an assert. NOTE: This is a candidate for the 8.0 branch.
Diffstat (limited to 'src/mesa/main/uniform_query.cpp')
-rw-r--r--src/mesa/main/uniform_query.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 869f7d373ba..991df7896b4 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -203,10 +203,18 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
const union gl_constant_value *const src =
&uni->storage[offset * elements];
- unsigned bytes = sizeof(uni->storage[0]) * elements;
- if (bytes > (unsigned) bufSize) {
- elements = bufSize / sizeof(uni->storage[0]);
- bytes = bufSize;
+ assert(returnType == GLSL_TYPE_FLOAT || returnType == GLSL_TYPE_INT ||
+ returnType == GLSL_TYPE_UINT);
+ /* The three (currently) supported types all have the same size,
+ * which is of course the same as their union. That'll change
+ * with glGetUniformdv()...
+ */
+ unsigned bytes = sizeof(src[0]) * elements;
+ if (bufSize < 0 || bytes > (unsigned) bufSize) {
+ _mesa_error( ctx, GL_INVALID_OPERATION,
+ "glGetnUniform*vARB(out of bounds: bufSize is %d,"
+ " but %u bytes are required)", bufSize, bytes );
+ return;
}
/* If the return type and the uniform's native type are "compatible,"