From: Dmitry Volyntsev Date: Fri, 23 Aug 2019 17:00:40 +0000 (+0300) Subject: Increased max function nesting. X-Git-Tag: 0.3.6~50 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=15fc1a049a3d4d34c2c70757a9a9b49dd1ae7259;p=njs.git Increased max function nesting. --- diff --git a/src/njs_parser.c b/src/njs_parser.c index 02444e0e..18cecc91 100644 --- a/src/njs_parser.c +++ b/src/njs_parser.c @@ -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; } diff --git a/src/njs_vm.h b/src/njs_vm.h index 5daaaa38..2b2edbbf 100644 --- a/src/njs_vm.h +++ b/src/njs_vm.h @@ -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) diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 5206092b..d9209350 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -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"),