Fixed ASan array out of bounds.

Change-Id: I53366bd14548aa41c3d25bcd187d7436d47e8665
Tested: on Linux.
parent b752e4a9
...@@ -944,7 +944,7 @@ CheckedError Parser::ParseTableDelimiters(size_t &fieldn, ...@@ -944,7 +944,7 @@ CheckedError Parser::ParseTableDelimiters(size_t &fieldn,
if ((!opts.strict_json || !fieldn) && Is(terminator)) break; if ((!opts.strict_json || !fieldn) && Is(terminator)) break;
std::string name; std::string name;
if (is_nested_vector) { if (is_nested_vector) {
if (fieldn > struct_def->fields.vec.size()) { if (fieldn >= struct_def->fields.vec.size()) {
return Error("too many unnamed fields in nested array"); return Error("too many unnamed fields in nested array");
} }
name = struct_def->fields.vec[fieldn]->name; name = struct_def->fields.vec[fieldn]->name;
...@@ -1213,7 +1213,7 @@ CheckedError Parser::ParseNestedFlatbuffer(Value &val, FieldDef *field, ...@@ -1213,7 +1213,7 @@ CheckedError Parser::ParseNestedFlatbuffer(Value &val, FieldDef *field,
// Force alignment for nested flatbuffer // Force alignment for nested flatbuffer
builder_.ForceVectorAlignment(nested_parser.builder_.GetSize(), sizeof(uint8_t), builder_.ForceVectorAlignment(nested_parser.builder_.GetSize(), sizeof(uint8_t),
nested_parser.builder_.GetBufferMinAlignment()); nested_parser.builder_.GetBufferMinAlignment());
auto off = builder_.CreateVector(nested_parser.builder_.GetBufferPointer(), auto off = builder_.CreateVector(nested_parser.builder_.GetBufferPointer(),
nested_parser.builder_.GetSize()); nested_parser.builder_.GetSize());
val.constant = NumToString(off.o); val.constant = NumToString(off.o);
......
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