Skip to content

Commit

Permalink
Fixed "global" property handler when deleting.
Browse files Browse the repository at this point in the history
This fixes #734 issue.
  • Loading branch information
xeioex committed Jul 2, 2024
1 parent 6907216 commit 89aca30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/njs_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/test/njs_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]") },

Expand Down

0 comments on commit 89aca30

Please sign in to comment.