details:   
https://github.com/nginx/njs/commit/d5bcd36d321fb578ffd1c804ec2d206c3b3e945e
branches:  master
commit:    d5bcd36d321fb578ffd1c804ec2d206c3b3e945e
user:      Dmitry Volyntsev <xei...@nginx.com>
date:      Thu, 12 Jun 2025 17:20:07 -0700
description:
Fixed handling of detached buffer for typed arrays.


---
 src/njs_typed_array.c | 5 +++++
 src/njs_value.c       | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/njs_typed_array.c b/src/njs_typed_array.c
index f886dca6..d7ca2e83 100644
--- a/src/njs_typed_array.c
+++ b/src/njs_typed_array.c
@@ -655,6 +655,11 @@ njs_typed_array_set_value(njs_vm_t *vm, njs_typed_array_t 
*array,
         return ret;
     }
 
+    buffer = njs_typed_array_buffer(array);
+    if (njs_slow_path(njs_is_detached_buffer(buffer))) {
+        return NJS_OK;
+    }
+
     buffer = njs_typed_array_writable(vm, array);
     if (njs_slow_path(buffer == NULL)) {
         return NJS_ERROR;
diff --git a/src/njs_value.c b/src/njs_value.c
index 86fb6444..0c616a37 100644
--- a/src/njs_value.c
+++ b/src/njs_value.c
@@ -1019,8 +1019,7 @@ njs_value_property(njs_vm_t *vm, njs_value_t *value, 
uint32_t atom_id,
             tarray = njs_typed_array(value);
 
             if (njs_slow_path(njs_is_detached_buffer(tarray->buffer))) {
-                njs_type_error(vm, "detached buffer");
-                return NJS_ERROR;
+                goto not_found;
             }
 
             if (njs_slow_path(index >= njs_typed_array_length(tarray))) {
@@ -1109,6 +1108,7 @@ slow_path:
         break;
 
     case NJS_DECLINED:
+not_found:
         njs_set_undefined(retval);
 
         return NJS_DECLINED;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to