mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-01 19:43:56 +00:00
[idl_parser, JSON] Disable parsing of JSON for incomplete schemes (#6493)
This commit disable JSON parsing for an incomplete scheme if JSON object is embedded into one file with the scheme. This should improve the quality of OSS-Fuzz inputs for the parser_fuzzer target.
This commit is contained in:
@@ -3189,6 +3189,9 @@ CheckedError Parser::ParseRoot(const char *source, const char **include_paths,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Parse JSON object only if the scheme has been parsed.
|
||||||
|
if (token_ == '{') { ECHECK(DoParseJson()); }
|
||||||
|
EXPECT(kTokenEof);
|
||||||
return NoError();
|
return NoError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3308,7 +3311,7 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths,
|
|||||||
} else if (IsIdent("namespace")) {
|
} else if (IsIdent("namespace")) {
|
||||||
ECHECK(ParseNamespace());
|
ECHECK(ParseNamespace());
|
||||||
} else if (token_ == '{') {
|
} else if (token_ == '{') {
|
||||||
ECHECK(DoParseJson());
|
return NoError();
|
||||||
} else if (IsIdent("enum")) {
|
} else if (IsIdent("enum")) {
|
||||||
ECHECK(ParseEnum(false, nullptr));
|
ECHECK(ParseEnum(false, nullptr));
|
||||||
} else if (IsIdent("union")) {
|
} else if (IsIdent("union")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user