Cast to right type for reserved_ subtraction (#6167)
authorastange <stange@google.com>
Mon, 12 Oct 2020 16:14:45 +0000 (12:14 -0400)
committerGitHub <noreply@github.com>
Mon, 12 Oct 2020 16:14:45 +0000 (09:14 -0700)
reserved_ is a size_t so ensure that the output of cur_ - buf_ is cast to that to avoid compiler warnings.

include/flatbuffers/flatbuffers.h

index 69c8d71..b31191c 100644 (file)
@@ -933,7 +933,7 @@ class vector_downward {
   Allocator *get_custom_allocator() { return allocator_; }
 
   uoffset_t size() const {
-    return static_cast<uoffset_t>(reserved_ - (cur_ - buf_));
+    return static_cast<uoffset_t>(reserved_ - static_cast<size_t>(cur_ - buf_));
   }
 
   uoffset_t scratch_size() const {