]> git.kaiwu.me - njs.git/commitdiff
Fixed handling of detached buffer for typed arrays.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 13 Jun 2025 00:20:07 +0000 (17:20 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 13 Jun 2025 19:57:49 +0000 (12:57 -0700)
src/njs_typed_array.c
src/njs_value.c

index f886dca64b0fc8407312416d3b853a8f0e159565..d7ca2e838aec26589b855788f4d7a6889aebc5e0 100644 (file)
@@ -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;
index 86fb6444887e182f2fb730e6f046729e212e51f0..0c616a376b14b0718485a0564761403a8c54aa62 100644 (file)
@@ -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;