[Mesa-dev] [PATCH v3] mesa/uniform_query: Don't write to *params if there is an error

Kenneth Graunke kenneth at whitecape.org
Fri Dec 7 19:41:30 PST 2012


On 12/07/2012 04:34 PM, Matt Turner wrote:
> 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.
> ---
>   src/mesa/main/uniform_query.cpp |    6 +++++-
>   1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
> index cbdd39e..245e9a7 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:
>

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


More information about the mesa-dev mailing list