aco: fix stack buffer overflow in apply_sgprs()
authorRhys Perry <pendingchaos02@gmail.com>
Fri, 17 Jan 2020 11:35:20 +0000 (11:35 +0000)
committerMarge Bot <eric+marge@anholt.net>
Mon, 20 Jan 2020 11:13:11 +0000 (11:13 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Fixes: cef78797191 ('aco: rewrite apply_sgprs()')
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2361
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3442>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3442>

src/amd/compiler/aco_optimizer.cpp

index d8e42d88b7d53f37ce36860dec54f7c012793a6e..8c2514598f08b109f8094e66fe1c7f30f82f9832 100644 (file)
@@ -2112,7 +2112,8 @@ void apply_sgprs(opt_ctx &ctx, aco_ptr<Instruction>& 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()]++;
    }