Made the memcmp address sanitizer clean.

Added extra check to ensure memcmp gets called with a size that is
guaranteed within range of the buffer. This wasn't a real problem,
but stops address sanitizer from complaining.

See:
https://github.com/google/flatbuffers/issues/88
https://github.com/joker-eph/flatbuffers/commit/517506b4e105814e0823353c3d6561085c26a1ab#commitcomment-8265231

Change-Id: I7de24da2d36d973e154f92eeb3e093070886037f
Tested: on Linux
parent 8ef6ee2a
...@@ -540,7 +540,9 @@ class FlatBufferBuilder { ...@@ -540,7 +540,9 @@ class FlatBufferBuilder {
// See if we already have generated a vtable with this exact same // See if we already have generated a vtable with this exact same
// layout before. If so, make it point to the old one, remove this one. // layout before. If so, make it point to the old one, remove this one.
for (auto it = vtables_.begin(); it != vtables_.end(); ++it) { for (auto it = vtables_.begin(); it != vtables_.end(); ++it) {
if (memcmp(buf_.data_at(*it), vt1, vt1_size)) continue; auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*it));
auto vt2_size = *vt2;
if (vt1_size != vt2_size || memcmp(vt2, vt1, vt1_size)) continue;
vt_use = *it; vt_use = *it;
buf_.pop(GetSize() - vtableoffsetloc); buf_.pop(GetSize() - vtableoffsetloc);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment