]> git.kaiwu.me - njs.git/commitdiff
Increased max function nesting.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 23 Aug 2019 17:00:40 +0000 (20:00 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Fri, 23 Aug 2019 17:00:40 +0000 (20:00 +0300)
src/njs_parser.c
src/njs_vm.h
src/test/njs_unit_test.c

index 02444e0e2ea9f44acf10435140d52197bd5d61cd..18cecc918bffc8028a2dfa8faba2cbe6a042fc64 100644 (file)
@@ -153,7 +153,7 @@ njs_parser_scope_begin(njs_vm_t *vm, njs_parser_t *parser, njs_scope_t type)
             if (scope->type == NJS_SCOPE_FUNCTION) {
                 nesting = scope->nesting + 1;
 
-                if (nesting <= NJS_MAX_NESTING) {
+                if (nesting < NJS_MAX_NESTING) {
                     break;
                 }
 
index 5daaaa3891117ccbb13720951e427b9e49723877..2b2edbbf565f62afb0430030a5acc3df2414bc97 100644 (file)
@@ -59,9 +59,9 @@ typedef enum {
 
 /*
  * The maximum possible function nesting level is (16 - NJS_SCOPE_CLOSURE),
- * that is 11.  The 5 is reasonable limit.
+ * that is 11.  The 8 is reasonable limit.
  */
-#define NJS_MAX_NESTING        5
+#define NJS_MAX_NESTING        8
 
 #define NJS_SCOPES             (NJS_SCOPE_CLOSURE + NJS_MAX_NESTING)
 
index 5206092bd1307cf0077b71ac710a66b47703c267..d920935093e6adec94af0a0c5f82feac42140fca 100644 (file)
@@ -6559,9 +6559,24 @@ static njs_unit_test_t  njs_test[] =
     { njs_str("function x(a) { while (a < 2) a++; return a + 1 } x(1) "),
       njs_str("3") },
 
-    { njs_str("(function(){(function(){(function(){(function(){"
-                    "(function(){(function(){(function(){})})})})})})})"),
-      njs_str("SyntaxError: The maximum function nesting level is \"5\" in 1") },
+    { njs_str("(function(){"
+              "(function(){"
+              "(function(){"
+              "(function(){"
+              "(function(){"
+              "(function(){"
+              "(function(){"
+              "(function(){"
+              "(function(){})"
+              "})"
+              "})"
+              "})"
+              "})"
+              "})"
+              "})"
+              "})"
+              "})"),
+      njs_str("SyntaxError: The maximum function nesting level is \"8\" in 1") },
 
     { njs_str("Function.prototype.toString = function () {return 'X'};"
                  "eval"),