From: Alexander Borisov Date: Tue, 2 Jun 2020 14:53:27 +0000 (+0300) Subject: Fixed checking return value in primary expression. X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=7d9fae860bdf243804f995314efc521e65bb2b56;p=njs.git Fixed checking return value in primary expression. The issue was introduced in 86f55a7dc4a4. --- diff --git a/src/njs_parser.c b/src/njs_parser.c index 2f8ac72b..7d31857f 100644 --- a/src/njs_parser.c +++ b/src/njs_parser.c @@ -994,7 +994,7 @@ njs_parser_primary_expression_test(njs_parser_t *parser, ret = njs_parser_escape_string_create(parser, token, &node->u.value); if (ret != NJS_TOKEN_STRING) { - return NJS_DONE; + return NJS_ERROR; } parser->node = node; @@ -1005,7 +1005,7 @@ njs_parser_primary_expression_test(njs_parser_t *parser, njs_parser_syntax_error(parser, "Unterminated string \"%V\"", &token->text); - return NJS_DONE; + return NJS_ERROR; /* ArrayLiteral */ case NJS_TOKEN_OPEN_BRACKET: @@ -1086,7 +1086,7 @@ njs_parser_primary_expression_test(njs_parser_t *parser, ret = njs_parser_regexp_literal(parser, token, current); if (ret != NJS_OK) { - return NJS_DONE; + return NJS_ERROR; } goto done; @@ -2210,6 +2210,10 @@ njs_parser_member_expression(njs_parser_t *parser, njs_lexer_token_t *token, return NJS_OK; } + if (njs_is_error(&parser->vm->retval)) { + return NJS_DONE; + } + return ret; } diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 438a414b..36c9c080 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -16652,7 +16652,14 @@ static njs_unit_test_t njs_test[] = "function foo() {}"), njs_str("undefined") }, + { njs_str("new\""), + njs_str("SyntaxError: Unterminated string \"\"\" in 1") }, + { njs_str("new\"\\UFFFF"), + njs_str("SyntaxError: Unterminated string \"\"\\UFFFF\" in 1") }, + + { njs_str("new/la"), + njs_str("SyntaxError: Unterminated RegExp \"/la\" in 1") }, };