mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-04 17:51:10 +00:00
Fixed assert in flatc converting to text.
Change-Id: Idac375b22aa9beaba162084cc3396f5536a4e721 Tested: on Linux.
This commit is contained in:
@@ -582,6 +582,11 @@ class FlatBufferBuilder FLATBUFFERS_FINAL_CLASS {
|
|||||||
buf_.fill(PaddingBytes(buf_.size(), elem_size));
|
buf_.fill(PaddingBytes(buf_.size(), elem_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PushFlatBuffer(const uint8_t *bytes, size_t size) {
|
||||||
|
PushBytes(bytes, size);
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
|
||||||
void PushBytes(const uint8_t *bytes, size_t size) {
|
void PushBytes(const uint8_t *bytes, size_t size) {
|
||||||
buf_.push(bytes, size);
|
buf_.push(bytes, size);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,13 +201,13 @@ int main(int argc, const char *argv[]) {
|
|||||||
++file_it) {
|
++file_it) {
|
||||||
std::string contents;
|
std::string contents;
|
||||||
if (!flatbuffers::LoadFile(file_it->c_str(), true, &contents))
|
if (!flatbuffers::LoadFile(file_it->c_str(), true, &contents))
|
||||||
Error("unable to load file" + *file_it);
|
Error("unable to load file: " + *file_it);
|
||||||
|
|
||||||
bool is_binary = static_cast<size_t>(file_it - filenames.begin()) >=
|
bool is_binary = static_cast<size_t>(file_it - filenames.begin()) >=
|
||||||
binary_files_from;
|
binary_files_from;
|
||||||
if (is_binary) {
|
if (is_binary) {
|
||||||
parser.builder_.Clear();
|
parser.builder_.Clear();
|
||||||
parser.builder_.PushBytes(
|
parser.builder_.PushFlatBuffer(
|
||||||
reinterpret_cast<const uint8_t *>(contents.c_str()),
|
reinterpret_cast<const uint8_t *>(contents.c_str()),
|
||||||
contents.length());
|
contents.length());
|
||||||
if (!raw_binary) {
|
if (!raw_binary) {
|
||||||
|
|||||||
Reference in New Issue
Block a user