Disallow defaults on structs.

Change-Id: Ia098126c92ea6f8abe94561bd9c09b29ac8f61f5
Context: https://github.com/google/flatbuffers/issues/4591
Tested: on Linux.
This commit is contained in:
Wouter van Oortmerssen 2018-01-18 11:41:43 -08:00
parent 2265129e14
commit 3694ae0817
1 changed files with 3 additions and 2 deletions

View File

@ -648,8 +648,9 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
if (token_ == '=') {
NEXT();
if (!IsScalar(type.base_type))
return Error("default values currently only supported for scalars");
if (!IsScalar(type.base_type) || struct_def.fixed)
return Error(
"default values currently only supported for scalars in tables");
ECHECK(ParseSingleValue(field->value));
}
if (IsFloat(field->value.type.base_type)) {