llvmpipe: Do not need to free anything if there is no geometry shader.
authorVinson Lee <vlee@freedesktop.org>
Sun, 4 Aug 2013 08:18:28 +0000 (01:18 -0700)
committerVinson Lee <vlee@freedesktop.org>
Tue, 6 Aug 2013 04:54:20 +0000 (21:54 -0700)
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@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/llvmpipe/lp_state_gs.c

index b18795cdc4fdf46bd457be11d1769589bc47b81d..55da0f16a8de55f8b50ef7d745c81858bfb7ce12 100644 (file)
@@ -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);
 }