From: Alexander Borisov Date: Thu, 2 Sep 2021 16:33:03 +0000 (+0300) Subject: Parser: catching errors parsing in await expression. X-Git-Tag: 0.7.0~23 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=5d435d6a72e51e5b87ae69b0e4a008300d01ef36;p=njs.git Parser: catching errors parsing in await expression. The bug was introduced in 92d10cd761e2. --- diff --git a/src/njs_parser.c b/src/njs_parser.c index e02ae413..8ea51c26 100644 --- a/src/njs_parser.c +++ b/src/njs_parser.c @@ -3504,6 +3504,10 @@ static njs_int_t njs_parser_await_after(njs_parser_t *parser, njs_lexer_token_t *token, njs_queue_link_t *current) { + if (parser->ret != NJS_OK) { + return njs_parser_failed(parser); + } + parser->target->right = parser->node; parser->node = parser->target; diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 3b5cb67e..3e0d4dcc 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -20517,6 +20517,9 @@ static njs_unit_test_t njs_test[] = { njs_str("function f(a) {}" "(async function() {f('Number: ' + await 111)})"), njs_str("SyntaxError: await in arguments not supported in 1") }, + + { njs_str("async function af() {await encrypt({},}"), + njs_str("SyntaxError: Unexpected token \"}\" in 1") }, };