From 82d617e8b13dbc7e5467cea7ec4507a5f5daf35a Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Thu, 22 Feb 2024 13:00:09 +1100 Subject: [PATCH] glsl: fix potential crash in expression flattening The base_ir variable used by this pass is set via visit_list_elements() however this pass was skipping visit_list_elements() for the initial list of instructions i.e. it was skipping it for globals so if we ended up trying to flatten an expression on a global we would segfault. To quote the code comment on the base_ir variable: "This is implemented by visit_list_elements -- if the visitor is not called by it, nothing good will happen" Reviewed-by: Mike Blumenkrantz Part-of: --- src/compiler/glsl/ir_expression_flattening.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/compiler/glsl/ir_expression_flattening.cpp b/src/compiler/glsl/ir_expression_flattening.cpp index e4ca850d2f4..bd06be5274f 100644 --- a/src/compiler/glsl/ir_expression_flattening.cpp +++ b/src/compiler/glsl/ir_expression_flattening.cpp @@ -56,10 +56,7 @@ do_expression_flattening(exec_list *instructions, bool (*predicate)(ir_instruction *ir)) { ir_expression_flattening_visitor v(predicate); - - foreach_in_list(ir_instruction, ir, instructions) { - ir->accept(&v); - } + visit_list_elements(&v, instructions); } void