[Mesa-dev] [PATCH] llvmpipe: Do not need to free anything if there is no geometry shader.
Brian Paul
brianp at vmware.com
Mon Aug 5 07:05:39 PDT 2013
On 08/04/2013 02:25 AM, Vinson Lee wrote:
> If gs is null, then freeing state->shader.tokens would result in a null
> dereference.
>
> Fixes "Dereference after null check" defect reported by Coverity.
>
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
> src/gallium/drivers/llvmpipe/lp_state_gs.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/llvmpipe/lp_state_gs.c b/src/gallium/drivers/llvmpipe/lp_state_gs.c
> index b18795c..55da0f1 100644
> --- a/src/gallium/drivers/llvmpipe/lp_state_gs.c
> +++ b/src/gallium/drivers/llvmpipe/lp_state_gs.c
> @@ -100,8 +100,11 @@ llvmpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
> struct lp_geometry_shader *state =
> (struct lp_geometry_shader *)gs;
>
> - draw_delete_geometry_shader(llvmpipe->draw,
> - (state) ? state->draw_data : 0);
> + if (!state) {
> + return;
> + }
> +
> + draw_delete_geometry_shader(llvmpipe->draw, state->draw_data);
> FREE( (void *)state->shader.tokens );
> FREE(state);
> }
>
I think Coverity is being a little too picky here, but this fix is OK.
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the mesa-dev
mailing list