Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/flatbuffers/idl.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ class SymbolTable {
}

bool Add(const std::string& name, T* e) {
vec.emplace_back(e);
auto it = dict.find(name);
if (it != dict.end()) return true;
vec.emplace_back(e);
dict[name] = e;
return false;
}
Expand Down
29 changes: 29 additions & 0 deletions tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,34 @@ void EmbeddedSchemaAccess() {
EmbeddedSchemaAccessByType<StatT>();
}

void DuplicateEnumNameBinarySchemaTest() {
static const uint8_t duplicate_enum_name_schema[] = {
0x10, 0x00, 0x00, 0x00, 0x42, 0x46, 0x42, 0x53, 0x08, 0x00, 0x0c, 0x00,
0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x30, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00,
0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x4c, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x12, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x05, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x00, 0x08, 0x00, 0x07, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x44, 0x75, 0x70, 0x6c,
0x69, 0x63, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00,
0x0d, 0x00, 0x00, 0x00, 0x44, 0x75, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74,
0x65, 0x45, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00};

flatbuffers::Verifier verifier(duplicate_enum_name_schema,
sizeof(duplicate_enum_name_schema));
TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);

flatbuffers::Parser parser;
TEST_EQ(parser.Deserialize(duplicate_enum_name_schema,
sizeof(duplicate_enum_name_schema)),
false);
}

void NestedVerifierTest() {
// Create a nested monster.
flatbuffers::FlatBufferBuilder nested_builder;
Expand Down Expand Up @@ -1848,6 +1876,7 @@ int FlatBufferTests(const std::string& tests_data_path) {
FlexBuffersFloatingPointTest();
FlatbuffersIteratorsTest();
WarningsAsErrorsTest();
DuplicateEnumNameBinarySchemaTest();
NestedVerifierTest();
SizeVerifierTest();
PrivateAnnotationsLeaks();
Expand Down
Loading