[Mesa-dev] [PATCH] mesa: don't crash in KHR_no_error uniform variants when location == -1
Samuel Pitoiset
samuel.pitoiset at gmail.com
Sat May 13 15:39:32 UTC 2017
Mmh, this can still crash if location is < -1 or greater than the number
of uniforms. How about:
struct gl_uniform_storage *uni = NULL;
if (_mesa_is_no_error_enabled(ctx)) {
if (location >= 0 && location < shProg->NumUniformRemapTable)
uni = shProg->UniformRemapTable[location];
if (!uni)
return;
...
} else {
...
}
On 05/13/2017 08:31 AM, Timothy Arceri wrote:
> ---
> src/mesa/main/uniform_query.cpp | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
> index 0e02a76..5f38aa5 100644
> --- a/src/mesa/main/uniform_query.cpp
> +++ b/src/mesa/main/uniform_query.cpp
> @@ -904,20 +904,23 @@ validate_uniform(GLint location, GLsizei count, const GLvoid *values,
> extern "C" void
> _mesa_uniform(GLint location, GLsizei count, const GLvoid *values,
> struct gl_context *ctx, struct gl_shader_program *shProg,
> enum glsl_base_type basicType, unsigned src_components)
> {
> unsigned offset;
> int size_mul = glsl_base_type_is_64bit(basicType) ? 2 : 1;
>
> struct gl_uniform_storage *uni;
> if (_mesa_is_no_error_enabled(ctx)) {
> + if (location == -1)
> + return;
> +
> uni = shProg->UniformRemapTable[location];
>
> /* The array index specified by the uniform location is just the
> * uniform location minus the base location of of the uniform.
> */
> assert(uni->array_elements > 0 || location == (int)uni->remap_location);
> offset = location - uni->remap_location;
> } else {
> uni = validate_uniform(location, count, values, &offset, ctx, shProg,
> basicType, src_components);
>
More information about the mesa-dev
mailing list