st/mesa: move dereference after null check
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Tue, 1 Mar 2016 21:45:00 +0000 (14:45 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 2 Mar 2016 15:55:20 +0000 (08:55 -0700)
We should not dereference shader before we have done the
null check.

Reviewed-by: Erik Faye-Lund <kusmabite@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_atom_image.c

index 4b48bc30b6962c05ef97cd8f30a8f9619265f633..d0f0c42a3b37d0dd8cbfa7af1a3424451fd19cdf 100644 (file)
@@ -48,11 +48,13 @@ st_bind_images(struct st_context *st, struct gl_shader *shader,
 {
    unsigned i;
    struct pipe_image_view images[MAX_IMAGE_UNIFORMS];
-   struct gl_program_constants *c = &st->ctx->Const.Program[shader->Stage];
+   struct gl_program_constants *c;
 
    if (!shader || !st->pipe->set_shader_images)
       return;
 
+   c = &st->ctx->Const.Program[shader->Stage];
+
    for (i = 0; i < shader->NumImages; i++) {
       struct gl_image_unit *u = &st->ctx->ImageUnits[shader->ImageUnits[i]];
       struct st_texture_object *stObj = st_texture_object(u->TexObj);