From c8097afe2902c89d6d8a90c1948051680eaca9ae Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 18 Aug 2014 15:50:48 -0700 Subject: [PATCH] vc4: Avoid a null-deref if a sampler index isn't used. Part of fixing ARB_fragment_program/sparse-samplers --- src/gallium/drivers/vc4/vc4_program.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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; + } } } -- 2.30.2