@@ -206,6 +206,11 @@ ecma_builtin_typedarray_prototype_exec_routine (ecma_value_t this_arg, /**< this
206
206
207
207
ecma_object_t * obj_p = ecma_get_object_from_value (this_arg );
208
208
ecma_typedarray_info_t info = ecma_typedarray_get_info (obj_p );
209
+ ecma_object_t * arraybuffer_p = ecma_typedarray_get_arraybuffer (obj_p );
210
+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
211
+ {
212
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
213
+ }
209
214
210
215
ecma_typedarray_getter_fn_t typedarray_getter_cb = ecma_get_typedarray_getter_fn (info .id );
211
216
@@ -435,6 +440,12 @@ ecma_builtin_typedarray_prototype_map (ecma_value_t this_arg, /**< this argument
435
440
}
436
441
437
442
ecma_object_t * src_obj_p = ecma_get_object_from_value (this_arg );
443
+ ecma_object_t * arraybuffer_p = ecma_typedarray_get_arraybuffer (src_obj_p );
444
+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
445
+ {
446
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
447
+ }
448
+
438
449
ecma_typedarray_info_t src_info = ecma_typedarray_get_info (src_obj_p );
439
450
440
451
ecma_object_t * func_object_p = ecma_get_object_from_value (cb_func_val );
@@ -517,6 +528,12 @@ ecma_builtin_typedarray_prototype_reduce_with_direction (ecma_value_t this_arg,
517
528
}
518
529
519
530
ecma_object_t * obj_p = ecma_get_object_from_value (this_arg );
531
+ ecma_object_t * arraybuffer_p = ecma_typedarray_get_arraybuffer (obj_p );
532
+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
533
+ {
534
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
535
+ }
536
+
520
537
ecma_typedarray_info_t info = ecma_typedarray_get_info (obj_p );
521
538
522
539
ecma_typedarray_getter_fn_t getter_cb = ecma_get_typedarray_getter_fn (info .id );
@@ -770,6 +787,12 @@ ecma_builtin_typedarray_prototype_reverse (ecma_value_t this_arg) /**< this argu
770
787
}
771
788
772
789
ecma_object_t * obj_p = ecma_get_object_from_value (this_arg );
790
+ ecma_object_t * arraybuffer_p = ecma_typedarray_get_arraybuffer (obj_p );
791
+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
792
+ {
793
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
794
+ }
795
+
773
796
ecma_typedarray_info_t info = ecma_typedarray_get_info (obj_p );
774
797
775
798
uint32_t middle = (info .length / 2 ) << info .shift ;
@@ -822,9 +845,21 @@ ecma_op_typedarray_set_with_typedarray (ecma_value_t this_arg, /**< this argumen
822
845
}
823
846
824
847
ecma_object_t * target_typedarray_p = ecma_get_object_from_value (this_arg );
848
+ ecma_object_t * arraybuffer_p = ecma_typedarray_get_arraybuffer (target_typedarray_p );
849
+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
850
+ {
851
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
852
+ }
853
+
825
854
ecma_typedarray_info_t target_info = ecma_typedarray_get_info (target_typedarray_p );
826
855
827
856
ecma_object_t * src_typedarray_p = ecma_get_object_from_value (arr_val );
857
+ ecma_object_t * src_arraybuffer_p = ecma_typedarray_get_arraybuffer (src_typedarray_p );
858
+ if (ecma_arraybuffer_is_detached (src_arraybuffer_p ))
859
+ {
860
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
861
+ }
862
+
828
863
ecma_typedarray_info_t src_info = ecma_typedarray_get_info (src_typedarray_p );
829
864
830
865
uint32_t target_offset_uint32 = ecma_number_to_uint32 (target_offset_num );
@@ -911,6 +946,12 @@ ecma_builtin_typedarray_prototype_set (ecma_value_t this_arg, /**< this argument
911
946
912
947
/* 11. ~ 15. */
913
948
ecma_object_t * typedarray_p = ecma_get_object_from_value (this_arg );
949
+ ecma_object_t * arraybuffer_p = ecma_typedarray_get_arraybuffer (typedarray_p );
950
+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
951
+ {
952
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
953
+ }
954
+
914
955
ecma_typedarray_info_t target_info = ecma_typedarray_get_info (typedarray_p );
915
956
916
957
/* 16.~ 17. */
@@ -1476,6 +1517,11 @@ ecma_builtin_typedarray_prototype_sort (ecma_value_t this_arg, /**< this argumen
1476
1517
}
1477
1518
1478
1519
ecma_object_t * typedarray_p = ecma_get_object_from_value (this_arg );
1520
+ ecma_object_t * arraybuffer_p = ecma_typedarray_get_arraybuffer (typedarray_p );
1521
+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
1522
+ {
1523
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
1524
+ }
1479
1525
ecma_typedarray_info_t info = ecma_typedarray_get_info (typedarray_p );
1480
1526
1481
1527
if (!info .length )
@@ -1577,6 +1623,11 @@ ecma_builtin_typedarray_prototype_find_helper (ecma_value_t this_arg, /**< this
1577
1623
1578
1624
ecma_object_t * typedarray_p = ecma_get_object_from_value (this_arg );
1579
1625
ecma_typedarray_info_t info = ecma_typedarray_get_info (typedarray_p );
1626
+ ecma_object_t * arraybuffer_p = ecma_typedarray_get_arraybuffer (typedarray_p );
1627
+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
1628
+ {
1629
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
1630
+ }
1580
1631
1581
1632
uint32_t buffer_index = 0 ;
1582
1633
uint32_t limit = info .length * info .element_size ;
@@ -1678,6 +1729,11 @@ ecma_builtin_typedarray_prototype_index_helper (ecma_value_t this_arg, /**< this
1678
1729
1679
1730
ecma_object_t * typedarray_p = ecma_get_object_from_value (this_arg );
1680
1731
ecma_typedarray_info_t info = ecma_typedarray_get_info (typedarray_p );
1732
+ if (ecma_arraybuffer_is_detached (info .array_buffer_p ))
1733
+ {
1734
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
1735
+ }
1736
+
1681
1737
uint32_t limit = info .length * info .element_size ;
1682
1738
uint32_t from_index ;
1683
1739
@@ -1901,6 +1957,12 @@ ecma_builtin_typedarray_prototype_slice (ecma_value_t this_arg, /**< this argume
1901
1957
}
1902
1958
1903
1959
ecma_object_t * typedarray_p = ecma_get_object_from_value (this_arg );
1960
+ ecma_object_t * arraybuffer_p = ecma_typedarray_get_arraybuffer (typedarray_p );
1961
+ if (ecma_arraybuffer_is_detached (arraybuffer_p ))
1962
+ {
1963
+ return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached." ));
1964
+ }
1965
+
1904
1966
ecma_typedarray_info_t info = ecma_typedarray_get_info (typedarray_p );
1905
1967
uint32_t start = 0 ;
1906
1968
uint32_t end = info .length ;
@@ -1944,6 +2006,7 @@ ecma_builtin_typedarray_prototype_slice (ecma_value_t this_arg, /**< this argume
1944
2006
if (count > 0 )
1945
2007
{
1946
2008
ecma_object_t * new_typedarray_p = ecma_get_object_from_value (new_typedarray );
2009
+
1947
2010
lit_utf8_byte_t * new_typedarray_buffer_p = ecma_typedarray_get_buffer (new_typedarray_p );
1948
2011
uint32_t src_byte_index = (start * info .element_size );
1949
2012
0 commit comments