From: Jason Ekstrand Date: Wed, 10 Feb 2016 23:34:35 +0000 (-0800) Subject: nir/spirv: Assert that struct member ids are in-bounds X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac04c6de2c3abd2def23c43ede2458e4a61f7f6d;p=mesa.git nir/spirv: Assert that struct member ids are in-bounds --- diff --git a/src/compiler/nir/spirv/spirv_to_nir.c b/src/compiler/nir/spirv/spirv_to_nir.c index 979357d67c8..544251f5a1f 100644 --- a/src/compiler/nir/spirv/spirv_to_nir.c +++ b/src/compiler/nir/spirv/spirv_to_nir.c @@ -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 };