From 68f5277887aae1cdc202f45ecd44df2c3c59ba7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Fri, 10 Nov 2023 18:35:22 +0100 Subject: [PATCH] glsl: Make sure that the variable is a ir_variable before unreferencing it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While it technically was already only using an ir_instruction field, better make sure that it is effectively an ir_variable using the dedicated method instead of relying on an undefined behavior. Reviewed-by: Erik Faye-Lund Signed-off-by: Corentin Noël Part-of: --- src/compiler/glsl/opt_dead_builtin_variables.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/glsl/opt_dead_builtin_variables.cpp b/src/compiler/glsl/opt_dead_builtin_variables.cpp index 48452fc312e..c03c243ac5d 100644 --- a/src/compiler/glsl/opt_dead_builtin_variables.cpp +++ b/src/compiler/glsl/opt_dead_builtin_variables.cpp @@ -36,8 +36,9 @@ void optimize_dead_builtin_variables(exec_list *instructions, enum ir_variable_mode other) { - foreach_in_list_safe(ir_variable, var, instructions) { - if (var->ir_type != ir_type_variable || var->data.used) + foreach_in_list_safe(ir_instruction, inst, instructions) { + ir_variable *var = inst->as_variable(); + if (!var || var->data.used) continue; if (var->data.mode != ir_var_uniform