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

Matt Turner mattst88 at gmail.com
Fri Jul 12 11:10:36 PDT 2013


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.
---
 src/glsl/ast_function.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 3918263..e34c1dd 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -1707,6 +1707,11 @@ ast_aggregate_initializer::hir(exec_list *instructions,
    void *ctx = state;
    YYLTYPE loc = this->get_location();
    const char *name;
+
+   if (!this->constructor_type) {
+      _mesa_glsl_error(&loc, state, "type of C-style initializer unknown");
+      return ir_rvalue::error_value(ctx);
+   }
    const glsl_type *const constructor_type =
       this->constructor_type->glsl_type(&name, state);
 
-- 
1.8.1.5



More information about the mesa-dev mailing list