diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h index 5c42a7ed47..d0f2b36987 100644 --- a/include/flatbuffers/flexbuffers.h +++ b/include/flatbuffers/flexbuffers.h @@ -1983,8 +1983,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS { #undef FLEX_CHECK_VERIFIED bool VerifyTerminator(const String& s) { - return VerifyFromPointer(reinterpret_cast(s.c_str()), - s.size() + 1); + const uint8_t* ptr = reinterpret_cast(s.c_str()); + return VerifyFromPointer(ptr, s.size() + 1) && ptr[s.size()] == '\0'; } bool VerifyRef(Reference r) {