Added assert for referring to 0 offsets.
Change-Id: I7c04d934bfacd4aeaa2ba476b934dd3a62d4fc0e Tested: on Linux.
This commit is contained in:
parent
7c60937806
commit
48ff729477
|
@ -625,8 +625,10 @@ class FlatBufferBuilder FLATBUFFERS_FINAL_CLASS {
|
|||
// This function converts them to be relative to the current location
|
||||
// in the buffer (when stored here), pointing upwards.
|
||||
uoffset_t ReferTo(uoffset_t off) {
|
||||
Align(sizeof(uoffset_t)); // To ensure GetSize() below is correct.
|
||||
assert(off <= GetSize()); // Must refer to something already in buffer.
|
||||
// Align to ensure GetSize() below is correct.
|
||||
Align(sizeof(uoffset_t));
|
||||
// Offset must refer to something already in buffer.
|
||||
assert(off && off <= GetSize());
|
||||
return GetSize() - off + sizeof(uoffset_t);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue