draw: Fix regression in draw_set_sampler(_views).
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 24 Aug 2012 10:27:22 +0000 (11:27 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 24 Aug 2012 10:28:00 +0000 (11:28 +0100)
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.

src/gallium/auxiliary/draw/draw_context.c

index 4fc59a5d13388fa88a86c42506b3a0e469629c29..1aa9b615bc8e797fc405cf3909a1bdd12d868a6d 100644 (file)
@@ -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;