diff options
author | José Fonseca <[email protected]> | 2011-11-28 16:54:09 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2011-12-08 17:59:33 +0000 |
commit | f32c7232a8a16887af710a11f025381bc73640f0 (patch) | |
tree | bf9a3911c3b0cdd87e6310bd744a195c6d8502dc /src/gallium/drivers | |
parent | 24e648490921a386fc3f65d1b1ed330067a4bb25 (diff) |
llvmpipe,draw,gallivm: Ensure we don't walk beyond the end of the shader variant list.
u_simple_list.h uses a sentinel element, and not a NULL element. So
ensure list is not empty when reducing the list of shader variants.
Something I noticed while trying to free variants more aggressively.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_fs.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_setup.c | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 90f9271223c..26f8d7ff765 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1373,10 +1373,12 @@ llvmpipe_update_fs(struct llvmpipe_context *lp) if (lp->nr_fs_variants >= LP_MAX_SHADER_VARIANTS) { for (i = 0; i < LP_MAX_SHADER_VARIANTS / 4; i++) { struct lp_fs_variant_list_item *item; - item = last_elem(&lp->fs_variants_list); - if (!item) { + if (is_empty_list(&lp->fs_variants_list)) { break; } + item = last_elem(&lp->fs_variants_list); + assert(item); + assert(item->base); llvmpipe_remove_shader_variant(lp, item->base); } } diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c b/src/gallium/drivers/llvmpipe/lp_state_setup.c index 97c9238f989..3243abff6e0 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c @@ -837,7 +837,13 @@ cull_setup_variants(struct llvmpipe_context *lp) llvmpipe_finish(pipe, __FUNCTION__); for (i = 0; i < LP_MAX_SETUP_VARIANTS / 4; i++) { - struct lp_setup_variant_list_item *item = last_elem(&lp->setup_variants_list); + struct lp_setup_variant_list_item *item; + if (is_empty_list(&lp->setup_variants_list)) { + break; + } + item = last_elem(&lp->setup_variants_list); + assert(item); + assert(item->base); remove_setup_variant(lp, item->base); } } |