From 9284fd9c0d1855b1236d9630f3888f6320d9d7a8 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Wed, 3 Feb 2016 13:51:19 -0500 Subject: st/mesa: fix potential null deref if no shader is passed in Spotted by Coverity Signed-off-by: Ilia Mirkin Reviewed-by: Samuel Pitoiset --- src/mesa/state_tracker/st_atom_storagebuf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c b/src/mesa/state_tracker/st_atom_storagebuf.c index a581818d8c0..f165cc3e0a1 100644 --- a/src/mesa/state_tracker/st_atom_storagebuf.c +++ b/src/mesa/state_tracker/st_atom_storagebuf.c @@ -46,11 +46,13 @@ st_bind_ssbos(struct st_context *st, struct gl_shader *shader, { unsigned i; struct pipe_shader_buffer buffers[MAX_SHADER_STORAGE_BUFFERS]; - struct gl_program_constants *c = &st->ctx->Const.Program[shader->Stage]; + struct gl_program_constants *c; if (!shader || !st->pipe->set_shader_buffers) return; + c = &st->ctx->Const.Program[shader->Stage]; + for (i = 0; i < shader->NumShaderStorageBlocks; i++) { struct gl_shader_storage_buffer_binding *binding; struct st_buffer_object *st_obj; -- cgit v1.2.3