From: Eric Anholt Date: Mon, 18 Aug 2014 22:50:48 +0000 (-0700) Subject: vc4: Avoid a null-deref if a sampler index isn't used. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c8097afe2902c89d6d8a90c1948051680eaca9ae;p=mesa.git vc4: Avoid a null-deref if a sampler index isn't used. Part of fixing ARB_fragment_program/sparse-samplers --- diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 20f7a4489dc..fa598473aab 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1270,8 +1270,11 @@ static void vc4_setup_shared_key(struct vc4_key *key, struct vc4_texture_stateobj *texstate) { for (int i = 0; i < texstate->num_textures; i++) { - struct pipe_resource *prsc = texstate->textures[i]->texture; - key->tex_format[i] = prsc->format; + struct pipe_sampler_view *sampler = texstate->textures[i]; + if (sampler) { + struct pipe_resource *prsc = sampler->texture; + key->tex_format[i] = prsc->format; + } } }