nir/spirv: Assert that struct member ids are in-bounds
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 10 Feb 2016 23:34:35 +0000 (15:34 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 10 Feb 2016 23:36:41 +0000 (15:36 -0800)
src/compiler/nir/spirv/spirv_to_nir.c

index 979357d67c863f13a6ca9a5a7d47bcddb0d3c58c..544251f5a1f88a21e236314b30a0e6c065044bc0 100644 (file)
@@ -379,6 +379,7 @@ vtn_handle_decoration(struct vtn_builder *b, SpvOp opcode,
 }
 
 struct member_decoration_ctx {
+   unsigned num_fields;
    struct glsl_struct_field *fields;
    struct vtn_type *type;
 };
@@ -453,6 +454,8 @@ struct_member_decoration_cb(struct vtn_builder *b,
    if (member < 0)
       return;
 
+   assert(member < ctx->num_fields);
+
    switch (dec->decoration) {
    case SpvDecorationRelaxedPrecision:
       break; /* FIXME: Do nothing with this for now. */
@@ -671,6 +674,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
       }
 
       struct member_decoration_ctx ctx = {
+         .num_fields = num_fields,
          .fields = fields,
          .type = val->type
       };