Welcome! Log In Create A New Profile

Advanced

[njs] Fixed absolute scope in cloned VMs.

Anonymous User
November 22, 2024 01:56PM
details: https://github.com/nginx/njs/commit/11c36e925bc63633f8ca39ee2f237cc13fe5519d
branches: master
commit: 11c36e925bc63633f8ca39ee2f237cc13fe5519d
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed, 13 Nov 2024 21:14:34 -0800
description:
Fixed absolute scope in cloned VMs.


---
src/njs_vm.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/njs_vm.c b/src/njs_vm.c
index 908c40c8..90428cb4 100644
--- a/src/njs_vm.c
+++ b/src/njs_vm.c
@@ -384,7 +384,7 @@ njs_vm_clone(njs_vm_t *vm, njs_external_ptr_t external)
njs_mp_t *nmp;
njs_vm_t *nvm;
njs_int_t ret;
- njs_value_t **global;
+ njs_value_t **global, **value;

njs_thread_log_debug("CLONE:");

@@ -423,6 +423,24 @@ njs_vm_clone(njs_vm_t *vm, njs_external_ptr_t external)
goto fail;
}

+ if (nvm->options.unsafe) {
+ nvm->scope_absolute = njs_arr_create(nvm->mem_pool,
+ vm->scope_absolute->items,
+ sizeof(njs_value_t *));
+ if (njs_slow_path(nvm->scope_absolute == NULL)) {
+ goto fail;
+ }
+
+ value = njs_arr_add_multiple(nvm->scope_absolute,
+ vm->scope_absolute->items);
+ if (njs_slow_path(value == NULL)) {
+ goto fail;
+ }
+
+ memcpy(value, vm->scope_absolute->start,
+ vm->scope_absolute->items * sizeof(njs_value_t *));
+ }
+
nvm->levels[NJS_LEVEL_GLOBAL] = global;

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

[njs] Fixed absolute scope in cloned VMs.

Anonymous User 119 November 22, 2024 01:56PM



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

Online Users

Guests: 206
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