[Mesa-dev] [PATCH] mesa: fix type for array indexing validation

Tapani Pälli tapani.palli at intel.com
Sun Aug 2 23:05:05 PDT 2015


Reviewed-by: Tapani Pälli <tapani.palli at intel.com>

On 08/02/2015 04:47 AM, Timothy Arceri wrote:
> parse_program_resource_name returns -1 when the index is invalid this needs to
> be tested before assigning the value to the unsigned array_index.
>
> In link_varyings.cpp (the other place parse_program_resource_name is used) after
> the -1 check is done the value is just assigned to an unsigned variable so it
> seems long is just used so we can return the -1 rather than actually expecting
> index values to be ridiculously large.
>
> Cc: Matt Turner <mattst88 at gmail.com>
> Cc: Tapani Pälli <tapani.palli at intel.com>
> ---
>   src/mesa/main/shader_query.cpp | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
> index b49fd38..a85e4c4 100644
> --- a/src/mesa/main/shader_query.cpp
> +++ b/src/mesa/main/shader_query.cpp
> @@ -506,7 +506,7 @@ _mesa_program_resource_array_size(struct gl_program_resource *res)
>   static bool
>   valid_array_index(const GLchar *name, unsigned *array_index)
>   {
> -   unsigned idx = 0;
> +   long idx = 0;
>      const GLchar *out_base_name_end;
>
>      idx = parse_program_resource_name(name, &out_base_name_end);
>


More information about the mesa-dev mailing list