diff options
author | Vladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com> | 2021-03-02 04:40:58 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 13:40:58 -0800 |
commit | 5319dedb1a6480c2e9b7f6bcdb32549ab723493b (patch) | |
tree | 256ae166074a22f77ba31f60ec14583d6705fb0e /src/idl_parser.cpp | |
parent | bd4e0b30a7301b0fc134f10ea1bd618922b60a5c (diff) | |
download | flatbuffers-5319dedb1a6480c2e9b7f6bcdb32549ab723493b.tar.gz flatbuffers-5319dedb1a6480c2e9b7f6bcdb32549ab723493b.tar.bz2 flatbuffers-5319dedb1a6480c2e9b7f6bcdb32549ab723493b.zip |
[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.
Diffstat (limited to 'src/idl_parser.cpp')
-rw-r--r-- | src/idl_parser.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index 8cfd04bd..87b999d7 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -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(); } @@ -3308,7 +3311,7 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths, } else if (IsIdent("namespace")) { ECHECK(ParseNamespace()); } else if (token_ == '{') { - ECHECK(DoParseJson()); + return NoError(); } else if (IsIdent("enum")) { ECHECK(ParseEnum(false, nullptr)); } else if (IsIdent("union")) { |