summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniform_query.cpp
diff options
context:
space:
mode:
authorEduardo Lima Mitev <[email protected]>2015-01-21 15:32:47 +0100
committerIago Toral Quiroga <[email protected]>2015-02-03 13:19:36 +0100
commit0ed3bffc0850758924c86509b6135dbe2f017a52 (patch)
tree59ff9f6068b67e7715267f89b5443691beb0abb7 /src/mesa/main/uniform_query.cpp
parent284bd1ecdf3af2d1679baf588b3227cd34e3f15c (diff)
mesa: Returns a GL_INVALID_VALUE error on several APIs when buffer size is negative
Section 2.3.1 (Errors) of the OpenGL 4.5 spec says: "If a negative number is provided where an argument of type sizei or sizeiptr is specified, an INVALID_VALUE error is generated. This patch adds checks for negative buffer size values passed to different APIs. It also moves up the check on other APIs that already had it, making it the first error check performed in the function, for consistency. While there may be other APIs throughtout the code lacking this check (or at least not at the beginning of the function), this patch focuses on the cases that break the dEQP tests listed below. It could be a good excersize for the future to check all other cases, and improve consistency in the order of the checks throughout the whole Mesa code base. This fixes 5 dEQP test: * dEQP-GLES3.functional.negative_api.state.get_attached_shaders * dEQP-GLES3.functional.negative_api.state.get_shader_source * dEQP-GLES3.functional.negative_api.state.get_active_uniform * dEQP-GLES3.functional.negative_api.state.get_active_attrib * dEQP-GLES3.functional.negative_api.shader.program_binary Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main/uniform_query.cpp')
-rw-r--r--src/mesa/main/uniform_query.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 32870d0c492..d36f5067cbd 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -45,9 +45,14 @@ _mesa_GetActiveUniform(GLuint program, GLuint index,
GLenum *type, GLcharARB *nameOut)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_shader_program *shProg =
- _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform");
+ struct gl_shader_program *shProg;
+ if (maxLength < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(maxLength < 0)");
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform");
if (!shProg)
return;
@@ -85,16 +90,16 @@ _mesa_GetActiveUniformsiv(GLuint program,
struct gl_shader_program *shProg;
GLsizei i;
- shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform");
- if (!shProg)
- return;
-
if (uniformCount < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glGetActiveUniformsiv(uniformCount < 0)");
return;
}
+ shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform");
+ if (!shProg)
+ return;
+
for (i = 0; i < uniformCount; i++) {
GLuint index = uniformIndices[i];