Fixed Parser not checking size of union types vector
authorWouter van Oortmerssen <aardappel@gmail.com>
Mon, 14 Feb 2022 19:48:46 +0000 (11:48 -0800)
committerWouter van Oortmerssen <aardappel@gmail.com>
Mon, 14 Feb 2022 19:48:46 +0000 (11:48 -0800)
Change-Id: Ibcfc49a9c9376372bd15da2ed3a7f7a298863ccc

src/idl_parser.cpp

index 7e4cb08..47d01f0 100644 (file)
@@ -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));