[njs] Fixed checking return value in primary expression.

Alexander Borisov alexander.borisov at nginx.com
Tue Jun 2 14:54:19 UTC 2020


details:   https://hg.nginx.org/njs/rev/8923d0751c28
branches:  
changeset: 1413:8923d0751c28
user:      Alexander Borisov <alexander.borisov at nginx.com>
date:      Tue Jun 02 17:53:27 2020 +0300
description:
Fixed checking return value in primary expression.

The issue was introduced in 86f55a7dc4a4.

diffstat:

 src/njs_parser.c         |  10 +++++++---
 src/test/njs_unit_test.c |   9 ++++++++-
 2 files changed, 15 insertions(+), 4 deletions(-)

diffs (60 lines):

diff -r ff39edb94acf -r 8923d0751c28 src/njs_parser.c
--- a/src/njs_parser.c	Mon Jun 01 18:09:29 2020 +0300
+++ b/src/njs_parser.c	Tue Jun 02 17:53:27 2020 +0300
@@ -994,7 +994,7 @@ njs_parser_primary_expression_test(njs_p
 
         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_p
 
         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_p
 
         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_
                 return NJS_OK;
             }
 
+            if (njs_is_error(&parser->vm->retval)) {
+                return NJS_DONE;
+            }
+
             return ret;
         }
 
diff -r ff39edb94acf -r 8923d0751c28 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c	Mon Jun 01 18:09:29 2020 +0300
+++ b/src/test/njs_unit_test.c	Tue Jun 02 17:53:27 2020 +0300
@@ -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") },
 };
 
 


More information about the nginx-devel mailing list