summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-04-30 01:36:59 -0500
committerNicolai Hähnle <[email protected]>2016-05-07 16:46:58 -0500
commit945c6887ab43a98a6e042841b2fb547aaef250e2 (patch)
treedf666df2f4685ffb710270666f70210a9b49320f /src
parentbdad1393a04bd1c2ad99ed62978849796db162ed (diff)
compiler/glsl: do not downcast list sentinel
This crashes gcc's undefined behaviour sanitizer. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/ir.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 750f61744e7..d69ab131199 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -869,7 +869,8 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
/* Use each component from each entry in the value_list to initialize one
* component of the constant being constructed.
*/
- for (unsigned i = 0; i < type->components(); /* empty */) {
+ unsigned i = 0;
+ for (;;) {
assert(value->as_constant() != NULL);
assert(!value->is_tail_sentinel());
@@ -901,6 +902,8 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
break;
}
+ if (i >= type->components())
+ break; /* avoid downcasting a list sentinel */
value = (ir_constant *) value->next;
}
}