]> git.kaiwu.me - njs.git/commitdiff
Fixed checking return value in primary expression.
authorAlexander Borisov <alexander.borisov@nginx.com>
Tue, 2 Jun 2020 14:53:27 +0000 (17:53 +0300)
committerAlexander Borisov <alexander.borisov@nginx.com>
Tue, 2 Jun 2020 14:53:27 +0000 (17:53 +0300)
The issue was introduced in 86f55a7dc4a4.

src/njs_parser.c
src/test/njs_unit_test.c

index 2f8ac72b526b92da5d4aadf94db4610fa39d03db..7d31857f98dc2fe462545be6cc0fb5bf85339b68 100644 (file)
@@ -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;
         }
 
index 438a414b63c159fa9087dc9d46b83eff1dd01180..36c9c080b90ae506472f398bd92fc53d70b85c14 100644 (file)
@@ -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") },
 };