[njs] Fixed "global" property handler when deleting.
noreply at nginx.com
noreply at nginx.com
Tue Jul 2 02:33:02 UTC 2024
details: https://github.com/nginx/njs/commit/89aca305c471a17fa5bd83a94f091a9bdde7c6a3
branches: master
commit: 89aca305c471a17fa5bd83a94f091a9bdde7c6a3
user: Dmitry Volyntsev <xeioex at 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]") },
More information about the nginx-devel
mailing list