From ac04c6de2c3abd2def23c43ede2458e4a61f7f6d Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 10 Feb 2016 15:34:35 -0800 Subject: [PATCH] nir/spirv: Assert that struct member ids are in-bounds --- src/compiler/nir/spirv/spirv_to_nir.c | 4 ++++ 1 file changed, 4 insertions(+) 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 }; -- 2.30.2