Added error message for union values out of range.

Change-Id: I481afcde6a554d1cad519ff95acac7f38a7f4ee5
Tested: on Linux.
This commit is contained in:
Wouter van Oortmerssen
2017-05-10 17:21:47 -07:00
parent cfbab31fb1
commit 9d01bfaea3
2 changed files with 5 additions and 0 deletions

View File

@@ -1340,6 +1340,10 @@ CheckedError Parser::ParseEnum(bool is_union, EnumDef **dest) {
enum_def.vals.vec[prevsize - 1]->value >= ev.value)
return Error("enum values must be specified in ascending order");
}
if (is_union) {
if (ev.value < 0 || ev.value >= 256)
return Error("union enum value must fit in a ubyte");
}
if (opts.proto_mode && Is('[')) {
NEXT();
// ignore attributes on enums.