summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2020-02-06 11:49:39 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2020-02-06 11:56:28 -0800
commit8f56990f6cbb2ea260c9da3a2985568d5408d4dd (patch)
tree54ce428c36ce0a2d2756a15fedd488a31f081d4f
parent6400c9b054912ae4761ab3534248b51ffa7a6c1e (diff)
downloadflatbuffers-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.h1
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);