mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-29 06:40:02 +00:00
FlexBuffers: C++: scalar-only typed vectors were not aligned.
This means data written with older versions of this code has potentially misaligned data, which we'll need to support. This isn't a problem on most architectures, but could be on older ARM chips. To support them properly may require swapping out uses of `flatbuffers::ReadScalar` with a version that does a memcpy internally. Change-Id: Ib352aab4a586f3a8c6602fb25488dcfff61e06e0
This commit is contained in:
@@ -1494,6 +1494,7 @@ class Builder FLATBUFFERS_FINAL_CLASS {
|
|||||||
// TODO: instead of asserting, could write vector with larger elements
|
// TODO: instead of asserting, could write vector with larger elements
|
||||||
// instead, though that would be wasteful.
|
// instead, though that would be wasteful.
|
||||||
FLATBUFFERS_ASSERT(WidthU(len) <= bit_width);
|
FLATBUFFERS_ASSERT(WidthU(len) <= bit_width);
|
||||||
|
Align(bit_width);
|
||||||
if (!fixed) Write<uint64_t>(len, byte_width);
|
if (!fixed) Write<uint64_t>(len, byte_width);
|
||||||
auto vloc = buf_.size();
|
auto vloc = buf_.size();
|
||||||
for (size_t i = 0; i < len; i++) Write(elems[i], byte_width);
|
for (size_t i = 0; i < len; i++) Write(elems[i], byte_width);
|
||||||
|
|||||||
Reference in New Issue
Block a user