From dbce69c63b0f3cee8f6d9521479fd3b087338314 Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Sat, 29 Apr 2023 00:08:14 -0700 Subject: [PATCH] more window fixes --- src/binary_annotator.cpp | 4 ++-- src/binary_annotator.h | 2 +- src/reflection.cpp | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/binary_annotator.cpp b/src/binary_annotator.cpp index 2c31fe5f3d9..c5fa42f7297 100644 --- a/src/binary_annotator.cpp +++ b/src/binary_annotator.cpp @@ -26,7 +26,7 @@ static BinaryRegion MakeBinaryRegion( const uint64_t offset = 0, const uint64_t length = 0, const BinaryRegionType type = BinaryRegionType::Unknown, const uint64_t array_length = 0, const uint64_t points_to_offset = 0, - const BinaryRegionComment comment = {}) { + BinaryRegionComment comment = {}) { BinaryRegion region; region.offset = offset; region.length = length; @@ -39,7 +39,7 @@ static BinaryRegion MakeBinaryRegion( static BinarySection MakeBinarySection( const std::string &name, const BinarySectionType type, - const std::vector regions) { + std::vector regions) { BinarySection section; section.name = name; section.type = type; diff --git a/src/binary_annotator.h b/src/binary_annotator.h index 096f9a48151..fd0a9af0c7d 100644 --- a/src/binary_annotator.h +++ b/src/binary_annotator.h @@ -258,7 +258,7 @@ class BinaryAnnotator { uint16_t offset_from_table = 0; }; - const reflection::Object *referring_table; + const reflection::Object *referring_table = nullptr; // Field ID -> {field def, offset from table} std::map fields; diff --git a/src/reflection.cpp b/src/reflection.cpp index 6ea2d20b121..0d0814ef622 100644 --- a/src/reflection.cpp +++ b/src/reflection.cpp @@ -506,7 +506,9 @@ class ResizeContext { // Recurse. switch (base_type) { case reflection::Obj: { - ResizeTable(*subobjectdef, reinterpret_cast(ref)); + if (subobjectdef) { + ResizeTable(*subobjectdef, reinterpret_cast
(ref)); + } break; } case reflection::Vector: { @@ -564,7 +566,7 @@ void SetString(const reflection::Schema &schema, const std::string &val, // Clear the old string, since we don't want parts of it remaining. memset(flatbuf->data() + start, 0, str->size()); // Different size, we must expand (or contract). - ResizeContext(schema, start, delta, flatbuf, root_table); + ResizeContext ctx(schema, start, delta, flatbuf, root_table); // Set the new length. WriteScalar(flatbuf->data() + str_start, static_cast(val.size())); @@ -590,7 +592,7 @@ uint8_t *ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize, auto size_clear = -delta_elem * elem_size; memset(flatbuf->data() + start - size_clear, 0, size_clear); } - ResizeContext(schema, start, delta_bytes, flatbuf, root_table); + ResizeContext ctx(schema, start, delta_bytes, flatbuf, root_table); WriteScalar(flatbuf->data() + vec_start, newsize); // Length field. // Set new elements to 0.. this can be overwritten by the caller. if (delta_elem > 0) {