From 9c9fce96c7ce888a6b846612da985f5687bae638 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Mon, 19 Oct 2015 14:06:46 -0700 Subject: [PATCH] Vector of structs were not being verified correctly. Because they are represented as `const T *` in the Vector template, the sizeof(const T *) was accidentally used instead of sizeof(T). Change-Id: Ib4dc73e1d21396ba2e30c84e5e229c4147204bb1 Tested: on Linux. --- include/flatbuffers/flatbuffers.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 4c40da033..8f6933ba1 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -919,6 +919,11 @@ class Verifier FLATBUFFERS_FINAL_CLASS { &end); } + // Verify a pointer (may be NULL) of a vector to struct. + template bool Verify(const Vector *vec) const { + return Verify(reinterpret_cast *>(vec)); + } + // Verify a pointer (may be NULL) to string. bool Verify(const String *str) const { const uint8_t *end;