mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-29 08:42:00 +00:00
Added assert for referring to 0 offsets.
Change-Id: I7c04d934bfacd4aeaa2ba476b934dd3a62d4fc0e Tested: on Linux.
This commit is contained in:
@@ -625,8 +625,10 @@ class FlatBufferBuilder FLATBUFFERS_FINAL_CLASS {
|
|||||||
// This function converts them to be relative to the current location
|
// This function converts them to be relative to the current location
|
||||||
// in the buffer (when stored here), pointing upwards.
|
// in the buffer (when stored here), pointing upwards.
|
||||||
uoffset_t ReferTo(uoffset_t off) {
|
uoffset_t ReferTo(uoffset_t off) {
|
||||||
Align(sizeof(uoffset_t)); // To ensure GetSize() below is correct.
|
// Align to ensure GetSize() below is correct.
|
||||||
assert(off <= GetSize()); // Must refer to something already in buffer.
|
Align(sizeof(uoffset_t));
|
||||||
|
// Offset must refer to something already in buffer.
|
||||||
|
assert(off && off <= GetSize());
|
||||||
return GetSize() - off + sizeof(uoffset_t);
|
return GetSize() - off + sizeof(uoffset_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user