From 0d14e129bcc5a1691a6cfcb2672568600729f979 Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Mon, 30 Dec 2024 16:49:06 +0100 Subject: [PATCH] v3d: avoid 0-size variable length array Declaring a variable-length array (VLA) based on a variable that can be 0 is declared dangerous. In this case, the variable can't take value 0, so adding an assertion fixes the issue. This was detected by static analyzer. Reviewed-by: Iago Toral Quiroga Signed-off-by: Juan A. Suarez Romero Part-of: --- src/broadcom/compiler/vir_register_allocate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/broadcom/compiler/vir_register_allocate.c b/src/broadcom/compiler/vir_register_allocate.c index 25d7eba41e2..dfb5b9a989a 100644 --- a/src/broadcom/compiler/vir_register_allocate.c +++ b/src/broadcom/compiler/vir_register_allocate.c @@ -267,6 +267,8 @@ get_spill_type_for_temp(struct v3d_compile *c, int temp) static int v3d_choose_spill_node(struct v3d_compile *c) { + assert(c->num_temps > 1); + const float tmu_scale = 10; float block_scale = 1.0; float spill_costs[c->num_temps];