[Mesa-dev] [PATCH] glsl: Reject C-style initializers with unknown types.

Matt Turner mattst88 at gmail.com
Fri Jul 12 11:24:28 PDT 2013


On Fri, Jul 12, 2013 at 11:10 AM, Matt Turner <mattst88 at gmail.com> wrote:
> Previously, vec3 b = {{ 1.0, 2.0, 3.0 }} would cause a segfault because
> the we dereferenced the constructor_type field which was NULL.
>
> Arrays, structs, and matrices were unaffected.

This is a bad commit message. Use this instead:

_mesa_ast_set_aggregate_type walks through declarations initialized with
C-style aggregate initializers and stops when it runs out of LHS
declarations or RHS expressions.

In the example

   vec4 v = {{{1, 2, 3, 4}}};

_mesa_ast_set_aggregate_type would not recurse into the subexpressions
(since vec4s do not contain types that can be initialized with an
aggregate initializer) to set their <constructor_type>s. Later in ::hir
we would dereference the NULL pointer and segfault.

If <constructor_type> is NULL in ::hir we know that the LHS and RHS
were unbalanced and the code is illegal.

Arrays, structs, and matrices were unaffected.


More information about the mesa-dev mailing list