diff options
author | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-02-06 11:49:39 -0800 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-02-06 11:56:28 -0800 |
commit | 8f56990f6cbb2ea260c9da3a2985568d5408d4dd (patch) | |
tree | 54ce428c36ce0a2d2756a15fedd488a31f081d4f | |
parent | 6400c9b054912ae4761ab3534248b51ffa7a6c1e (diff) | |
download | flatbuffers-8f56990f6cbb2ea260c9da3a2985568d5408d4dd.tar.gz flatbuffers-8f56990f6cbb2ea260c9da3a2985568d5408d4dd.tar.bz2 flatbuffers-8f56990f6cbb2ea260c9da3a2985568d5408d4dd.zip |
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
-rw-r--r-- | include/flatbuffers/flexbuffers.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h index fee0e993..7c179f0e 100644 --- a/include/flatbuffers/flexbuffers.h +++ b/include/flatbuffers/flexbuffers.h @@ -1494,6 +1494,7 @@ class Builder FLATBUFFERS_FINAL_CLASS { // TODO: instead of asserting, could write vector with larger elements // instead, though that would be wasteful. FLATBUFFERS_ASSERT(WidthU(len) <= bit_width); + Align(bit_width); if (!fixed) Write<uint64_t>(len, byte_width); auto vloc = buf_.size(); for (size_t i = 0; i < len; i++) Write(elems[i], byte_width); |