diff options
author | Erik Faye-Lund <erik.faye-lund@collabora.com> | 2021-03-29 13:21:47 +0200 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-03-30 15:22:17 +0000 |
commit | 89a04a54c41b1ffd3f6699273bf1486afa37b96c (patch) | |
tree | 058688beb8e38237224a7f840cef45d23d133002 | |
parent | cb580af02a40c7f65b5c8445e93d22447c738cde (diff) |
compiler/glsl: avoid null-pointer deref
When we encounter a bindless image here, lower_deref returns a
NULL-pointer, and calling record_images_used will try to dereference
that NULL-pointer.
So let's dig out the var from the source instruction instead of the
result of the lowering.
Fixes: 5910c938a29 ("nir/glsl: gather bitmask of images used by program")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9895>
-rw-r--r-- | src/compiler/glsl/gl_nir_lower_samplers_as_deref.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c index 0174c25642a..26a74cf761e 100644 --- a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c +++ b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c @@ -120,9 +120,10 @@ remove_struct_derefs_prep(nir_deref_instr **p, char **name, static void record_images_used(struct shader_info *info, - nir_deref_instr *deref) + nir_intrinsic_instr *instr) { - nir_variable *var = nir_deref_instr_get_variable(deref); + nir_variable *var = + nir_deref_instr_get_variable(nir_src_as_deref(instr->src[0])); /* Structs have been lowered already, so get_aoa_size is sufficient. */ const unsigned size = @@ -301,7 +302,7 @@ lower_intrinsic(nir_intrinsic_instr *instr, nir_deref_instr *deref = lower_deref(b, state, nir_src_as_deref(instr->src[0])); - record_images_used(&state->shader->info, deref); + record_images_used(&state->shader->info, instr); /* don't lower bindless: */ if (!deref) |