From feea8fed44331bc19f6e8869a7c0d421b50b9054 Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Thu, 24 Mar 2022 11:15:58 +0800 Subject: [PATCH] mesa/program: fix nir output reg overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit outputs_written is uint64_t, should count max reg number by util_last_bit64(). Otherwise the following access will overflow the allocated array with a smaller size. cc: mesa-stable Reviewed-by: Marek Olšák Reviewed-by: Pierre-Eric Pelloux-Prayer Signed-off-by: Qiang Yu Part-of: --- src/mesa/program/prog_to_nir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c index cf5c5b1be2e..5cd073d565e 100644 --- a/src/mesa/program/prog_to_nir.c +++ b/src/mesa/program/prog_to_nir.c @@ -916,7 +916,7 @@ setup_registers_and_variables(struct ptn_compile *c) } /* Create output registers and variables. */ - int max_outputs = util_last_bit(c->prog->info.outputs_written); + int max_outputs = util_last_bit64(c->prog->info.outputs_written); c->output_regs = rzalloc_array(c, nir_register *, max_outputs); uint64_t outputs_written = c->prog->info.outputs_written;