Skip to content

Commit 032f5c8

Browse files
committed
Fixed handling of detached buffer for typed arrays.
1 parent 743eb5d commit 032f5c8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/njs_typed_array.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,11 @@ njs_typed_array_set_value(njs_vm_t *vm, njs_typed_array_t *array,
655655
return ret;
656656
}
657657

658+
buffer = njs_typed_array_buffer(array);
659+
if (njs_slow_path(njs_is_detached_buffer(buffer))) {
660+
return NJS_OK;
661+
}
662+
658663
buffer = njs_typed_array_writable(vm, array);
659664
if (njs_slow_path(buffer == NULL)) {
660665
return NJS_ERROR;

src/njs_value.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,7 @@ njs_value_property(njs_vm_t *vm, njs_value_t *value, uint32_t atom_id,
10191019
tarray = njs_typed_array(value);
10201020

10211021
if (njs_slow_path(njs_is_detached_buffer(tarray->buffer))) {
1022-
njs_type_error(vm, "detached buffer");
1023-
return NJS_ERROR;
1022+
goto not_found;
10241023
}
10251024

10261025
if (njs_slow_path(index >= njs_typed_array_length(tarray))) {
@@ -1109,6 +1108,7 @@ njs_value_property(njs_vm_t *vm, njs_value_t *value, uint32_t atom_id,
11091108
break;
11101109

11111110
case NJS_DECLINED:
1111+
not_found:
11121112
njs_set_undefined(retval);
11131113

11141114
return NJS_DECLINED;

0 commit comments

Comments
 (0)