mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-05 21:17:25 +00:00
Fix recursion counter check. Add control to override depth of nested … (#4953)
* Fix recursion counter check. Add control to override depth of nested objects. * Change if-condition to `>=`
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
c0698cc33f
commit
925c1d77fc
@@ -115,8 +115,8 @@ CheckedError Parser::Error(const std::string &msg) {
|
||||
inline CheckedError NoError() { return CheckedError(false); }
|
||||
|
||||
CheckedError Parser::RecurseError() {
|
||||
return Error("maximum parsing recursion of " + NumToString(kMaxParsingDepth) +
|
||||
" reached");
|
||||
return Error("maximum parsing recursion of " +
|
||||
NumToString(FLATBUFFERS_MAX_PARSING_DEPTH) + " reached");
|
||||
}
|
||||
|
||||
inline std::string OutOfRangeErrorMsg(int64_t val, const std::string &op,
|
||||
@@ -2254,7 +2254,10 @@ bool Parser::ParseFlexBuffer(const char *source, const char *source_filename,
|
||||
|
||||
bool Parser::Parse(const char *source, const char **include_paths,
|
||||
const char *source_filename) {
|
||||
return !ParseRoot(source, include_paths, source_filename).Check();
|
||||
FLATBUFFERS_ASSERT(0 == recurse_protection_counter);
|
||||
auto r = !ParseRoot(source, include_paths, source_filename).Check();
|
||||
FLATBUFFERS_ASSERT(0 == recurse_protection_counter);
|
||||
return r;
|
||||
}
|
||||
|
||||
CheckedError Parser::StartParseFile(const char *source,
|
||||
|
||||
Reference in New Issue
Block a user