[njs] Fixed for(expr1; conditional syntax error handling.

Vadim Zhestikov v.zhestikov at f5.com
Fri Nov 18 22:12:04 UTC 2022


details:   https://hg.nginx.org/njs/rev/c51adee54dfe
branches:  
changeset: 2007:c51adee54dfe
user:      Vadim Zhestikov <v.zhestikov at f5.com>
date:      Fri Nov 18 14:10:25 2022 -0800
description:
Fixed for(expr1; conditional syntax error handling.

diffstat:

 src/njs_parser.c         |  4 ++++
 src/test/njs_unit_test.c |  3 +++
 2 files changed, 7 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r 8163612eb950 -r c51adee54dfe src/njs_parser.c
--- a/src/njs_parser.c	Thu Nov 17 20:38:23 2022 -0800
+++ b/src/njs_parser.c	Fri Nov 18 14:10:25 2022 -0800
@@ -5652,6 +5652,10 @@ static njs_int_t
 njs_parser_expression_continue_assign_comma(njs_parser_t *parser,
     njs_lexer_token_t *token, njs_queue_link_t *current)
 {
+    if (parser->ret != NJS_OK) {
+        return njs_parser_failed(parser);
+    }
+
     njs_parser_next(parser, njs_parser_assignment_expression_after);
 
     return njs_parser_after(parser, current, NULL, 1,
diff -r 8163612eb950 -r c51adee54dfe src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c	Thu Nov 17 20:38:23 2022 -0800
+++ b/src/test/njs_unit_test.c	Fri Nov 18 14:10:25 2022 -0800
@@ -2968,6 +2968,9 @@ static njs_unit_test_t  njs_test[] =
     { njs_str("for(9A=>>"),
       njs_str("SyntaxError: Unexpected token \"A\" in 1") },
 
+    { njs_str("for(A?{,"),
+      njs_str("SyntaxError: Unexpected token \",\" in 1") },
+
     /* switch. */
 
     { njs_str("switch"),



More information about the nginx-devel mailing list