From 5f8a8716b6b58a470be0b0d176e38d37eda2c8f7 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 7 Dec 2012 16:32:30 -0800 Subject: [PATCH] mesa/uniform_query: Don't write to *params if there is an error The GL 3.1 and ES 3.0 specs say of glGetActiveUniformsiv: "If an error occurs, nothing will be written to params." So, make a pass through the indices and check that they're valid before the pass that actually writes to params. Checking pname happens on the first iteration of the second loop. Fixes es3conform's getactiveuniformsiv_for_nonexistent_uniform_indices test. NOTE: This is a candidate for the 9.0 branch. Reviewed-by: Brian Paul Reviewed-by: Kenneth Graunke (cherry picked from commit 11cea472466f731fa9c44d56f1643dec26e6601c) --- src/mesa/main/uniform_query.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index bddb8f95e14..8a1de27720a 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -97,12 +97,16 @@ _mesa_GetActiveUniformsiv(GLuint program, for (i = 0; i < uniformCount; i++) { GLuint index = uniformIndices[i]; - const struct gl_uniform_storage *uni = &shProg->UniformStorage[index]; if (index >= shProg->NumUserUniformStorage) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniformsiv(index)"); return; } + } + + for (i = 0; i < uniformCount; i++) { + GLuint index = uniformIndices[i]; + const struct gl_uniform_storage *uni = &shProg->UniformStorage[index]; switch (pname) { case GL_UNIFORM_TYPE: