From f353fd886465f3fd6b96ed34804003f8cc3572fb Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Tue, 10 Feb 2015 13:54:22 +0100 Subject: [PATCH] Fix pointer underrun when allocating large vectors Change-Id: Ia69fc3098468eb64420215dc1068342ccbbb1ede --- include/flatbuffers/flatbuffers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index a20b5bfb2..d6b6e9a71 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -367,7 +367,7 @@ class vector_downward { } uint8_t *make_space(size_t len) { - if (buf_ > cur_ - len) { + if (len > static_cast(cur_ - buf_)) { auto old_size = size(); reserved_ += std::max(len, growth_policy(reserved_)); auto new_buf = allocator_.allocate(reserved_);