diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index 7e4cb08fd..47d01f0f0 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -1128,6 +1128,9 @@ CheckedError Parser::ParseAnyValue(Value &val, FieldDef *field, } uint8_t enum_idx; if (vector_of_union_types) { + if (vector_of_union_types->size() <= count) + return Error("union types vector smaller than union values vector" + " for: " + field->name); enum_idx = vector_of_union_types->Get(count); } else { ECHECK(atot(constant.c_str(), *this, &enum_idx));