Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/flatbuffers/flatbuffer_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {

void Align(size_t elem_size) {
TrackMinAlign(elem_size);
buf_.fill(PaddingBytes(buf_.size(), elem_size));
buf_.fill(PaddingBytes(static_cast<size_t>(buf_.size()), elem_size));
}

void PushFlatBuffer(const uint8_t *bytes, size_t size) {
Expand Down Expand Up @@ -516,7 +516,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
void PreAlign(size_t len, size_t alignment) {
if (len == 0) return;
TrackMinAlign(alignment);
buf_.fill(PaddingBytes(GetSize() + len, alignment));
buf_.fill(PaddingBytes(static_cast<size_t>(GetSize()) + len, alignment));
}

// Aligns such than when "len" bytes are written, an object of type `AlignT`
Expand Down Expand Up @@ -712,7 +712,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
ForceVectorAlignment(len, elemsize, alignment);

// Update the 64 bit region.
length_of_64_bit_region_ = GetSize();
length_of_64_bit_region_ = static_cast<size_t>(GetSize());
}

// Similar to ForceVectorAlignment but for String fields.
Expand Down
4 changes: 2 additions & 2 deletions include/flatbuffers/vector_downward.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ template<typename SizeT = uoffset_t> class vector_downward {

void reallocate(size_t len) {
auto old_reserved = reserved_;
auto old_size = size();
auto old_scratch_size = scratch_size();
auto old_size = static_cast<size_t>(size());
auto old_scratch_size = static_cast<size_t>(scratch_size());
reserved_ +=
(std::max)(len, old_reserved ? old_reserved / 2 : initial_size_);
reserved_ = (reserved_ + buffer_minalign_ - 1) & ~(buffer_minalign_ - 1);
Expand Down
6 changes: 3 additions & 3 deletions include/flatbuffers/verifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
template<typename OffsetT = uoffset_t, typename SOffsetT = soffset_t>
size_t VerifyOffset(const size_t start) const {
if (!Verify<OffsetT>(start)) return 0;
const auto o = ReadScalar<OffsetT>(buf_ + start);
const auto o = static_cast<size_t>(ReadScalar<OffsetT>(buf_ + start));
// May not point to itself.
if (!Check(o != 0)) return 0;
// Can't wrap around larger than the max size.
if (!Check(static_cast<SOffsetT>(o) >= 0)) return 0;
// Must be inside the buffer to create a pointer from it (pointer outside
// buffer is UB).
if (!Verify(start + o, 1)) return 0;
return o;
if (!static_cast<size_t>(Verify(start + o, 1))) return 0;
return static_cast<size_t>(o);
}

template<typename OffsetT = uoffset_t>
Expand Down