[njs] Increased max function nesting.
Dmitry Volyntsev
xeioex at nginx.com
Fri Aug 23 18:50:04 UTC 2019
details: https://hg.nginx.org/njs/rev/a3e8a7a51161
branches:
changeset: 1142:a3e8a7a51161
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Fri Aug 23 20:00:40 2019 +0300
description:
Increased max function nesting.
diffstat:
src/njs_parser.c | 2 +-
src/njs_vm.h | 4 ++--
src/test/njs_unit_test.c | 21 ++++++++++++++++++---
3 files changed, 21 insertions(+), 6 deletions(-)
diffs (58 lines):
diff -r 8057f3ad56c1 -r a3e8a7a51161 src/njs_parser.c
--- a/src/njs_parser.c Fri Aug 23 15:13:45 2019 +0300
+++ b/src/njs_parser.c Fri Aug 23 20:00:40 2019 +0300
@@ -153,7 +153,7 @@ njs_parser_scope_begin(njs_vm_t *vm, njs
if (scope->type == NJS_SCOPE_FUNCTION) {
nesting = scope->nesting + 1;
- if (nesting <= NJS_MAX_NESTING) {
+ if (nesting < NJS_MAX_NESTING) {
break;
}
diff -r 8057f3ad56c1 -r a3e8a7a51161 src/njs_vm.h
--- a/src/njs_vm.h Fri Aug 23 15:13:45 2019 +0300
+++ b/src/njs_vm.h Fri Aug 23 20:00:40 2019 +0300
@@ -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 -r 8057f3ad56c1 -r a3e8a7a51161 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Fri Aug 23 15:13:45 2019 +0300
+++ b/src/test/njs_unit_test.c Fri Aug 23 20:00:40 2019 +0300
@@ -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"),
More information about the nginx-devel
mailing list