@@ -151,6 +151,12 @@ ecma_builtin_typedarray_prototype_exec_routine (ecma_value_t this_arg, /**< this
151151 return call_value ;
152152 }
153153
154+ if (ecma_arraybuffer_is_detached (info_p -> array_buffer_p ))
155+ {
156+ ecma_free_value (call_value );
157+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
158+ }
159+
154160 bool to_bool_result = ecma_op_to_boolean (call_value );
155161 ecma_free_value (call_value );
156162
@@ -238,6 +244,13 @@ ecma_builtin_typedarray_prototype_map (ecma_value_t this_arg, /**< this object *
238244 return mapped_value ;
239245 }
240246
247+ if (ecma_arraybuffer_is_detached (src_info_p -> array_buffer_p ))
248+ {
249+ ecma_free_value (mapped_value );
250+ ecma_free_value (new_typedarray );
251+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
252+ }
253+
241254 uint32_t target_byte_pos = index << target_info .shift ;
242255 ecma_value_t set_element = target_typedarray_setter_cb (target_info .buffer_p + target_byte_pos , mapped_value );
243256 ecma_free_value (mapped_value );
@@ -341,6 +354,12 @@ ecma_builtin_typedarray_prototype_reduce_with_direction (ecma_value_t this_arg,
341354 return call_value ;
342355 }
343356
357+ if (ecma_arraybuffer_is_detached (info_p -> array_buffer_p ))
358+ {
359+ ecma_free_value (call_value );
360+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
361+ }
362+
344363 accumulator = call_value ;
345364
346365 if (is_right )
@@ -416,6 +435,13 @@ ecma_builtin_typedarray_prototype_filter (ecma_value_t this_arg, /**< this objec
416435 goto cleanup ;
417436 }
418437
438+ if (ecma_arraybuffer_is_detached (info_p -> array_buffer_p ))
439+ {
440+ ecma_free_value (call_value );
441+ ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
442+ goto cleanup ;
443+ }
444+
419445 if (ecma_op_to_boolean (call_value ))
420446 {
421447 memcpy (pass_value_p , info_p -> buffer_p + byte_pos , info_p -> element_size );
@@ -693,6 +719,13 @@ ecma_builtin_typedarray_prototype_set (ecma_value_t this_arg, /**< this argument
693719
694720 ecma_free_value (elem );
695721
722+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
723+ {
724+ ecma_deref_object (source_obj_p );
725+ ecma_free_value (value_to_set );
726+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
727+ }
728+
696729 ecma_value_t set_element = target_typedarray_setter_cb (target_info .buffer_p + target_byte_index , value_to_set );
697730
698731 ecma_free_value (value_to_set );
@@ -1008,6 +1041,11 @@ ecma_builtin_typedarray_prototype_fill (ecma_value_t this_arg, /**< this object
10081041 uint32_t byte_index = begin_index_uint32 * info_p -> element_size ;
10091042 uint32_t limit = byte_index + subarray_length * info_p -> element_size ;
10101043
1044+ if (ecma_arraybuffer_is_detached (info_p -> array_buffer_p ))
1045+ {
1046+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
1047+ }
1048+
10111049 while (byte_index < limit )
10121050 {
10131051 ecma_value_t set_element = typedarray_setter_cb (info_p -> buffer_p + byte_index , value_to_set );
@@ -1038,7 +1076,8 @@ ecma_builtin_typedarray_prototype_fill (ecma_value_t this_arg, /**< this object
10381076static ecma_value_t
10391077ecma_builtin_typedarray_prototype_sort_compare_helper (ecma_value_t lhs , /**< left value */
10401078 ecma_value_t rhs , /**< right value */
1041- ecma_value_t compare_func ) /**< compare function */
1079+ ecma_value_t compare_func , /**< compare function */
1080+ ecma_object_t * array_buffer_p ) /**< array buffer */
10421081{
10431082 if (ecma_is_value_undefined (compare_func ))
10441083 {
@@ -1110,6 +1149,12 @@ ecma_builtin_typedarray_prototype_sort_compare_helper (ecma_value_t lhs, /**< le
11101149 return number_result ;
11111150 }
11121151
1152+ if (ecma_arraybuffer_is_detached (array_buffer_p ))
1153+ {
1154+ ecma_free_value (number_result );
1155+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
1156+ }
1157+
11131158 // If the coerced value can't be represented as a Number, compare them as equals.
11141159 if (ecma_number_is_nan (ret_num ))
11151160 {
@@ -1164,7 +1209,8 @@ ecma_builtin_typedarray_prototype_sort (ecma_value_t this_arg, /**< this argumen
11641209 ecma_value_t sort_value = ecma_builtin_helper_array_merge_sort_helper (values_buffer ,
11651210 (uint32_t ) (info_p -> length ),
11661211 compare_func ,
1167- sort_cb );
1212+ sort_cb ,
1213+ info_p -> array_buffer_p );
11681214
11691215 if (ECMA_IS_VALUE_ERROR (sort_value ))
11701216 {
@@ -1174,6 +1220,11 @@ ecma_builtin_typedarray_prototype_sort (ecma_value_t this_arg, /**< this argumen
11741220
11751221 JERRY_ASSERT (sort_value == ECMA_VALUE_EMPTY );
11761222
1223+ if (ecma_arraybuffer_is_detached (info_p -> array_buffer_p ))
1224+ {
1225+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
1226+ }
1227+
11771228 ecma_typedarray_setter_fn_t typedarray_setter_cb = ecma_get_typedarray_setter_fn (info_p -> id );
11781229
11791230 byte_index = 0 ;
@@ -1248,6 +1299,13 @@ ecma_builtin_typedarray_prototype_find_helper (ecma_value_t this_arg, /**< this
12481299 return call_value ;
12491300 }
12501301
1302+ if (ecma_arraybuffer_is_detached (info_p -> array_buffer_p ))
1303+ {
1304+ ecma_free_value (element_value );
1305+ ecma_free_value (call_value );
1306+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
1307+ }
1308+
12511309 bool call_result = ecma_op_to_boolean (call_value );
12521310 ecma_free_value (call_value );
12531311
@@ -1466,6 +1524,11 @@ ecma_builtin_typedarray_prototype_copy_within (ecma_value_t this_arg, /**< this
14661524 }
14671525 }
14681526
1527+ if (ecma_arraybuffer_is_detached (info_p -> array_buffer_p ))
1528+ {
1529+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
1530+ }
1531+
14691532 if (relative_target >= info_p -> length || relative_start >= relative_end || relative_end == 0 )
14701533 {
14711534 return ecma_copy_value (this_arg );
@@ -1538,6 +1601,12 @@ ecma_builtin_typedarray_prototype_slice (ecma_value_t this_arg, /**< this argume
15381601 {
15391602 ecma_object_t * new_typedarray_p = ecma_get_object_from_value (new_typedarray );
15401603
1604+ if (ecma_arraybuffer_is_detached (info_p -> array_buffer_p ))
1605+ {
1606+ ecma_deref_object (new_typedarray_p );
1607+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
1608+ }
1609+
15411610 lit_utf8_byte_t * new_typedarray_buffer_p = ecma_typedarray_get_buffer (new_typedarray_p );
15421611 uint32_t src_byte_index = (relative_start * info_p -> element_size );
15431612
@@ -1673,6 +1742,11 @@ ecma_builtin_typedarray_prototype_includes (ecma_typedarray_info_t *info_p, /**<
16731742
16741743 uint32_t search_pos = (uint32_t ) from_index * info_p -> element_size ;
16751744
1745+ if (ecma_arraybuffer_is_detached (info_p -> array_buffer_p ))
1746+ {
1747+ return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
1748+ }
1749+
16761750 while (search_pos < limit )
16771751 {
16781752 ecma_value_t element = getter_cb (info_p -> buffer_p + search_pos );
0 commit comments