From e151398de61f53ecc6b19a34d33748a4c9e99abf Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 17 Jan 2020 11:35:20 +0000 Subject: [PATCH] aco: fix stack buffer overflow in apply_sgprs() Signed-off-by: Rhys Perry Fixes: cef78797191 ('aco: rewrite apply_sgprs()') Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2361 Tested-by: Marge Bot Part-of: --- src/amd/compiler/aco_optimizer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index d8e42d88b7d..8c2514598f0 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -2112,7 +2112,8 @@ void apply_sgprs(opt_ctx &ctx, aco_ptr& instr) continue; } - sgpr_ids[num_sgprs++] = sgpr.id(); + if (new_sgpr) + sgpr_ids[num_sgprs++] = sgpr.id(); ctx.uses[sgpr_info_id]--; ctx.uses[sgpr.id()]++; } -- 2.30.2