compiler/glsl: do not downcast list sentinel

This crashes gcc's undefined behaviour sanitizer.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Nicolai Hähnle
2016-04-30 01:36:59 -05:00
parent bdad1393a0
commit 945c6887ab

View File

@@ -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 /* Use each component from each entry in the value_list to initialize one
* component of the constant being constructed. * 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->as_constant() != NULL);
assert(!value->is_tail_sentinel()); assert(!value->is_tail_sentinel());
@@ -901,6 +902,8 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
break; break;
} }
if (i >= type->components())
break; /* avoid downcasting a list sentinel */
value = (ir_constant *) value->next; value = (ir_constant *) value->next;
} }
} }