Replace 'assert' by 'FLATBUFFERS_ASSERT' inside idl_parser.cpp (#5799)

This commit is contained in:
Vladimir Glavnyy
2020-03-13 01:18:10 +07:00
committed by GitHub
parent 35abb7f89b
commit d10c163142

View File

@@ -1336,7 +1336,7 @@ CheckedError Parser::ParseVector(const Type &type, uoffset_t *ovalue,
break; break;
} }
} }
assert(key); FLATBUFFERS_ASSERT(key);
// Now sort it. // Now sort it.
// We can't use std::sort because for structs the size is not known at // We can't use std::sort because for structs the size is not known at
// compile time, and for tables our iterators dereference offsets, so can't // compile time, and for tables our iterators dereference offsets, so can't
@@ -1386,7 +1386,7 @@ CheckedError Parser::ParseVector(const Type &type, uoffset_t *ovalue,
// These are serialized offsets, so are relative where they are // These are serialized offsets, so are relative where they are
// stored in memory, so compute the distance between these pointers: // stored in memory, so compute the distance between these pointers:
ptrdiff_t diff = (b - a) * sizeof(Offset<Table>); ptrdiff_t diff = (b - a) * sizeof(Offset<Table>);
assert(diff >= 0); // Guaranteed by SimpleQsort. FLATBUFFERS_ASSERT(diff >= 0); // Guaranteed by SimpleQsort.
auto udiff = static_cast<uoffset_t>(diff); auto udiff = static_cast<uoffset_t>(diff);
a->o = EndianScalar(ReadScalar<uoffset_t>(a) - udiff); a->o = EndianScalar(ReadScalar<uoffset_t>(a) - udiff);
b->o = EndianScalar(ReadScalar<uoffset_t>(b) + udiff); b->o = EndianScalar(ReadScalar<uoffset_t>(b) + udiff);