Welcome! Log In Create A New Profile

Advanced

[njs] Fixed double declaration detection in modules.

Vadim Zhestikov via nginx-devel
October 06, 2022 09:32PM
details: https://hg.nginx.org/njs/rev/16442fa970ee
branches:
changeset: 1975:16442fa970ee
user: Vadim Zhestikov <v.zhestikov@f5.com>
date: Thu Oct 06 18:28:52 2022 -0700
description:
Fixed double declaration detection in modules.

diffstat:

src/njs_variable.c | 15 +++++++++------
src/test/njs_unit_test.c | 4 ++++
2 files changed, 13 insertions(+), 6 deletions(-)

diffs (41 lines):

diff -r 80b59b59b7d8 -r 16442fa970ee src/njs_variable.c
--- a/src/njs_variable.c Fri Sep 30 17:40:57 2022 -0700
+++ b/src/njs_variable.c Thu Oct 06 18:28:52 2022 -0700
@@ -222,14 +222,17 @@ njs_variable_scope_find(njs_parser_t *pa
return root;
}

- module = parser->vm->options.module || parser->module;
+ if (scope->parent == NULL) {
+ module = parser->vm->options.module || parser->module;

- if (module) {
- if (type == NJS_VARIABLE_FUNCTION
- || var->type == NJS_VARIABLE_FUNCTION)
- {
- goto failed;
+ if (module) {
+ if (type == NJS_VARIABLE_FUNCTION
+ || var->type == NJS_VARIABLE_FUNCTION)
+ {
+ goto failed;
+ }
}
+
}

return root;
diff -r 80b59b59b7d8 -r 16442fa970ee src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Fri Sep 30 17:40:57 2022 -0700
+++ b/src/test/njs_unit_test.c Thu Oct 06 18:28:52 2022 -0700
@@ -21296,6 +21296,10 @@ static njs_unit_test_t njs_module_test[

{ njs_str("{ var f = 1; } function f() {};"),
njs_str("SyntaxError: \"f\" has already been declared in 1") },
+
+ { njs_str("function f(v) {var f = v;}; f(1); f"),
+ njs_str("[object Function]") },
+
};


_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] Fixed double declaration detection in modules.

Vadim Zhestikov via nginx-devel 217 October 06, 2022 09:32PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 51
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready