From d798100be99989f5cd7d67b175b3ec7b4512d53b Mon Sep 17 00:00:00 2001 From: Sahil Jain Date: Wed, 15 Feb 2017 14:42:01 -0500 Subject: [PATCH] Round vector_downward initial size up (#4179) --- include/flatbuffers/flatbuffers.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 83b4fa1cd..47e375702 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -496,12 +496,11 @@ class vector_downward { public: explicit vector_downward(size_t initial_size, const simple_allocator &allocator) - : reserved_(initial_size), + : reserved_((initial_size + sizeof(largest_scalar_t) - 1) & + ~(sizeof(largest_scalar_t) - 1)), buf_(allocator.allocate(reserved_)), cur_(buf_ + reserved_), - allocator_(allocator) { - assert((initial_size & (sizeof(largest_scalar_t) - 1)) == 0); - } + allocator_(allocator) {} ~vector_downward() { if (buf_)