Don't pass negative token id to Lemon parser Newer Lemon versions throw an assertion if they encounter invalid token ids.
Fixes LUCY-327. Thanks to Petr Pisar for the report. Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/3a9128ce Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/3a9128ce Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/3a9128ce Branch: refs/heads/0.6 Commit: 3a9128ce1f957140a14ad1aaf0bc7bdcfe41f9b5 Parents: 480527e Author: Nick Wellnhofer <[email protected]> Authored: Thu Feb 8 14:29:11 2018 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Thu Feb 8 16:14:01 2018 +0100 ---------------------------------------------------------------------- core/Lucy/Util/Json.c | 6 ++++++ 1 file changed, 6 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/3a9128ce/core/Lucy/Util/Json.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c index 46a0b89..be19660 100644 --- a/core/Lucy/Util/Json.c +++ b/core/Lucy/Util/Json.c @@ -479,6 +479,12 @@ S_do_parse_json(void *json_parser, const char *json, size_t len) { } break; } + if (token_type < 0) { + // Clear out parser and return. + LucyParseJson(json_parser, 0, NULL, &state); + SET_ERROR("JSON syntax error", save, end); + return NULL; + } LucyParseJson(json_parser, token_type, value, &state); if (state.errors) { SET_ERROR("JSON syntax error", save, end);
