[Mesa-dev] [PATCH v2 2/2] i965: Fix invalid pointer read in dead_control_flow_eliminate().

Kenneth Graunke kenneth at whitecape.org
Mon Apr 4 05:56:37 UTC 2016


There may not be a previous block.  In this case, there's no real work
to do, so just continue on to the next one.

v2: Update for bblock->prev() API change.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp b/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp
index 2c1abaf..114dc6c 100644
--- a/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp
+++ b/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp
@@ -42,6 +42,10 @@ dead_control_flow_eliminate(backend_shader *s)
 
    foreach_block_safe (block, s->cfg) {
       bblock_t *prev_block = block->prev();
+
+      if (!prev_block)
+         continue;
+
       backend_instruction *const inst = block->start();
       backend_instruction *const prev_inst = prev_block->end();
 
-- 
2.7.4



More information about the mesa-dev mailing list