From: Dmitry Volyntsev Date: Thu, 12 Jun 2025 22:16:41 +0000 (-0700) Subject: Fixed %TypedArray%.from() with buffer is detached by mapper. X-Git-Tag: 0.9.1~27 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=d10a85b24981ad2ba602da7b29c870cc596fda70;p=njs.git Fixed %TypedArray%.from() with buffer is detached by mapper. --- diff --git a/src/njs_typed_array.c b/src/njs_typed_array.c index 19399e3b..83e3b9f1 100644 --- a/src/njs_typed_array.c +++ b/src/njs_typed_array.c @@ -324,13 +324,14 @@ static njs_int_t njs_typed_array_from(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t unused, njs_value_t *retval) { - double num; - int64_t length, i; - njs_int_t ret; - njs_value_t *this, *source, *mapfn; - njs_value_t arguments[3], value; - njs_function_t *function; - njs_typed_array_t *array; + double num; + int64_t length, i; + njs_int_t ret; + njs_value_t *this, *source, *mapfn; + njs_value_t arguments[3], value; + njs_function_t *function; + njs_typed_array_t *array; + njs_array_buffer_t *buffer; this = njs_argument(args, 0); @@ -371,6 +372,7 @@ njs_typed_array_from(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, } array = njs_typed_array(retval); + buffer = njs_typed_array_buffer(array); arguments[0] = *njs_arg(args, nargs, 3); for (i = 0; i < length; i++) { @@ -393,7 +395,9 @@ njs_typed_array_from(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, return NJS_ERROR; } - njs_typed_array_prop_set(vm, array, i, num); + if (!njs_is_detached_buffer(buffer)) { + njs_typed_array_prop_set(vm, array, i, num); + } } njs_set_typed_array(retval, array);