Welcome! Log In Create A New Profile

Advanced

[njs] Fixed "global" property handler when deleting.

Anonymous User
July 01, 2024 10:34PM
details: https://github.com/nginx/njs/commit/89aca305c471a17fa5bd83a94f091a9bdde7c6a3
branches: master
commit: 89aca305c471a17fa5bd83a94f091a9bdde7c6a3
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed, 26 Jun 2024 19:12:38 -0700
description:
Fixed "global" property handler when deleting.

This fixes #734 issue.

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

diff --git a/src/njs_builtin.c b/src/njs_builtin.c
index 6c38cbee..3ff6f547 100644
--- a/src/njs_builtin.c
+++ b/src/njs_builtin.c
@@ -783,13 +783,14 @@ njs_global_this_object(njs_vm_t *vm, njs_object_prop_t *self,
njs_object_prop_t *prop;
njs_lvlhsh_query_t lhq;

+ if (retval == NULL) {
+ return NJS_DECLINED;
+ }
+
njs_value_assign(retval, global);

if (njs_slow_path(setval != NULL)) {
njs_value_assign(retval, setval);
-
- } else if (njs_slow_path(retval == NULL)) {
- return NJS_DECLINED;
}

prop = njs_object_prop_alloc(vm, &self->name, retval, 1);
diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c
index e63b0336..96c922bc 100644
--- a/src/test/njs_unit_test.c
+++ b/src/test/njs_unit_test.c
@@ -12885,6 +12885,9 @@ static njs_unit_test_t njs_test[] =
{ njs_str("var ex; try {({}) instanceof this} catch (e) {ex = e}; ex"),
njs_str("TypeError: right argument is not callable") },

+ { njs_str("delete global.global; global"),
+ njs_str("ReferenceError: \"global\" is not defined") },
+
{ njs_str("njs"),
njs_str("[object njs]") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed "global" property handler when deleting.

Anonymous User 127 July 01, 2024 10:34PM



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

Online Users

Guests: 178
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready