Skip to content
Open
Changes from all commits
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
10 changes: 10 additions & 0 deletions src/binary_annotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ std::map<uint64_t, BinarySection> BinaryAnnotator::Annotate() {
}
}

// The bfbs schema's `root_table` field is optional (see
// reflection/reflection.fbs Schema.root_table) and `RootTable()` may also
// return null when an explicit root-table-name override is set but the
// named table is not present in `schema_->objects()`. Without a root
// table we cannot meaningfully annotate the binary, so bail gracefully
// instead of dereferencing a null pointer in BuildHeader / BuildTable
// below. Mirrors the fix applied to bfbs_gen_lua.cpp in #8770.
const reflection::Object* const root = RootTable();
if (root == nullptr || root->name() == nullptr) { return {}; }

// The binary is too short to read as a flatbuffers.
if (binary_length_ < FLATBUFFERS_MIN_BUFFER_SIZE) {
return {};
Expand Down