[Mesa-dev] [PATCH v2 3/5] compiler/glsl: avoid downcasting list sentinel nodes (v2)

Nicolai Hähnle nhaehnle at gmail.com
Fri May 13 04:50:51 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

This avoids undefined downcasting of list sentinels that crashes gcc's ubsan.

v2: don't use a new macro (Ian Romanick)
---
 src/compiler/glsl/opt_tree_grafting.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/opt_tree_grafting.cpp b/src/compiler/glsl/opt_tree_grafting.cpp
index b9db41b..60840b0 100644
--- a/src/compiler/glsl/opt_tree_grafting.cpp
+++ b/src/compiler/glsl/opt_tree_grafting.cpp
@@ -323,9 +323,10 @@ try_tree_grafting(ir_assignment *start,
       fprintf(stderr, "\n");
    }
 
-   for (ir_instruction *ir = (ir_instruction *)start->next;
-	ir != bb_last->next;
-	ir = (ir_instruction *)ir->next) {
+   for (exec_node *node = start->next;
+        node != bb_last->next;
+        node = node->next) {
+      ir_instruction *const ir = (ir_instruction *) node;
 
       if (debug) {
 	 fprintf(stderr, "- ");
-- 
2.7.4



More information about the mesa-dev mailing list