diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index a33092f3d..c78583cad 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -1222,7 +1222,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS { // must be 0. auto size = ReadScalar(vec); auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size; - Check(size < max_elems); // Protect against byte_size overflowing. + if (!Check(size < max_elems)) + return false; // Protect against byte_size overflowing. auto byte_size = sizeof(size) + elem_size * size; *end = vec + byte_size; return Verify(vec, byte_size);