From: José Fonseca Date: Fri, 24 Aug 2012 10:27:22 +0000 (+0100) Subject: draw: Fix regression in draw_set_sampler(_views). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3e3f99277df947a96029580dc4e66ae38a93f004;p=mesa.git draw: Fix regression in draw_set_sampler(_views). draw->samplers(_views) now has PIPE_SHADER_TYPES elements, instead of PIPE_MAX_SAMPLERS as before. Also, shader_stage must be less than PIPE_SHADER_TYPES to prevent buffer overflow. Trivial. --- diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 4fc59a5d133..1aa9b615bc8 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -760,12 +760,12 @@ draw_set_sampler_views(struct draw_context *draw, { unsigned i; - debug_assert(num <= Elements(draw->sampler_views)); - debug_assert(shader_stage <= PIPE_SHADER_TYPES); + debug_assert(shader_stage < PIPE_SHADER_TYPES); + debug_assert(num <= PIPE_MAX_SAMPLERS); for (i = 0; i < num; ++i) draw->sampler_views[shader_stage][i] = views[i]; - for (i = num; i < Elements(draw->sampler_views); ++i) + for (i = num; i < PIPE_MAX_SAMPLERS; ++i) draw->sampler_views[shader_stage][i] = NULL; draw->num_sampler_views[shader_stage] = num; @@ -779,12 +779,12 @@ draw_set_samplers(struct draw_context *draw, { unsigned i; - debug_assert(num <= Elements(draw->samplers)); - debug_assert(shader_stage <= PIPE_SHADER_TYPES); + debug_assert(shader_stage < PIPE_SHADER_TYPES); + debug_assert(num <= PIPE_MAX_SAMPLERS); for (i = 0; i < num; ++i) draw->samplers[shader_stage][i] = samplers[i]; - for (i = num; i < Elements(draw->samplers); ++i) + for (i = num; i < PIPE_MAX_SAMPLERS; ++i) draw->samplers[shader_stage][i] = NULL; draw->num_samplers[shader_stage] = num;