[Mesa-dev] [PATCH] glsl: Fix array overflow.

Brian Paul brianp at vmware.com
Thu Aug 16 10:29:03 PDT 2012


On 08/14/2012 07:40 PM, Stéphane Marchesin wrote:
> Otherwise we run past the end of the array and crash.
>
> NOTE: This is a candidate for the 8.0 branch.
>
> Signed-off-by: Stéphane Marchesin<marcheu at chromium.org>
> ---
>   src/glsl/link_uniforms.cpp |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
> index 25dc1d7..eef9025 100644
> --- a/src/glsl/link_uniforms.cpp
> +++ b/src/glsl/link_uniforms.cpp
> @@ -313,7 +313,7 @@ private:
>   	 const gl_texture_index target = base_type->sampler_index();
>   	 const unsigned shadow = base_type->sampler_shadow;
>   	 for (unsigned i = this->uniforms[id].sampler
> -		 ; i<  this->next_sampler
> +		 ; i<  MIN2(this->next_sampler, MAX_SAMPLERS)
>   		 ; i++) {
>   	    this->targets[i] = target;
>   	    this->shader_samplers_used |= 1U<<  i;

Hi Stéphane,

I wonder if we should be checking earlier if the number of samplers 
exceeds the GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS limit.  Ian, Eric?

-Brian


More information about the mesa-dev mailing list