Commit a2485d4e authored by Mark Nauwelaerts's avatar Mark Nauwelaerts Committed by Wouter van Oortmerssen

reflection: check for valid union enum value during object verification (#5475)

... to avoid assertion failure or invalid access due to invalid vector index
parent a20e71ac
......@@ -656,6 +656,7 @@ bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
if (utype != 0) {
// Means we have this union field present
auto fb_enum = schema.enums()->Get(field_def->type()->index());
if (utype >= fb_enum->values()->size()) return false;
auto child_obj = fb_enum->values()->Get(utype)->object();
if (!VerifyObject(v, schema, *child_obj,
flatbuffers::GetFieldT(*table, *field_def),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment