From: Dmitry Volyntsev Date: Fri, 13 Jun 2025 00:20:07 +0000 (-0700) Subject: Fixed handling of detached buffer for typed arrays. X-Git-Tag: 0.9.1~25 X-Git-Url: http://www.kaiwu.me/sitemap.xml?a=commitdiff_plain;h=d5bcd36d321fb578ffd1c804ec2d206c3b3e945e;p=njs.git Fixed handling of detached buffer for typed arrays. --- 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;