File tree Expand file tree Collapse file tree 4 files changed +34
-5
lines changed Expand file tree Collapse file tree 4 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -2608,8 +2608,15 @@ namespace Js
2608
2608
#endif
2609
2609
Js::TypeId instanceType = JavascriptOperators::GetTypeId (instance);
2610
2610
// Fast path for native and typed arrays.
2611
- if ( (instanceType == TypeIds_NativeIntArray || instanceType == TypeIds_NativeFloatArray) || (instanceType >= TypeIds_Int8Array && instanceType <= TypeIds_Uint64Array) )
2611
+ bool isNativeArray = instanceType == TypeIds_NativeIntArray || instanceType == TypeIds_NativeFloatArray;
2612
+ bool isTypedArray = instanceType >= TypeIds_Int8Array && instanceType <= TypeIds_Uint64Array;
2613
+ if (isNativeArray || isTypedArray)
2612
2614
{
2615
+ // Check if the typed array is detached to prevent an exception in GetOwnItem
2616
+ if (isTypedArray && TypedArrayBase::IsDetachedTypedArray (instance))
2617
+ {
2618
+ return FALSE ;
2619
+ }
2613
2620
RecyclableObject* object = RecyclableObject::FromVar (instance);
2614
2621
Var member = nullptr ;
2615
2622
@@ -4504,7 +4511,7 @@ namespace Js
4504
4511
ScriptContext* scriptContext,
4505
4512
PropertyOperationFlags flags)
4506
4513
{
4507
-
4514
+
4508
4515
INT_PTR vt = (INT_PTR)nullptr ;
4509
4516
vt = VirtualTableInfoBase::GetVirtualTable (instance);
4510
4517
@@ -4565,7 +4572,7 @@ namespace Js
4565
4572
PropertyOperationFlags flags,
4566
4573
double dValue)
4567
4574
{
4568
-
4575
+
4569
4576
INT_PTR vt = (INT_PTR)nullptr ;
4570
4577
vt = VirtualTableInfoBase::GetVirtualTable (instance);
4571
4578
Original file line number Diff line number Diff line change @@ -1131,7 +1131,8 @@ namespace Js
1131
1131
1132
1132
BOOL TypedArrayBase::IsDetachedTypedArray (Var aValue)
1133
1133
{
1134
- return Is (aValue) && FromVar (aValue)->IsDetachedBuffer ();
1134
+ TypedArrayBase* arr = JavascriptOperators::TryFromVar<TypedArrayBase>(aValue);
1135
+ return arr && arr->IsDetachedBuffer ();
1135
1136
}
1136
1137
1137
1138
void TypedArrayBase::Set (TypedArrayBase* source, uint32 offset)
@@ -1158,7 +1159,7 @@ namespace Js
1158
1159
if (GetTypeId () == source->GetTypeId () ||
1159
1160
(GetBytesPerElement () == source->GetBytesPerElement ()
1160
1161
&& !((Uint8ClampedArray::Is (this ) || Uint8ClampedVirtualArray::Is (this )) && (Int8Array::Is (source) || Int8VirtualArray::Is (source)))
1161
- && !Float32Array::Is (this ) && !Float32Array::Is (source)
1162
+ && !Float32Array::Is (this ) && !Float32Array::Is (source)
1162
1163
&& !Float32VirtualArray::Is (this ) && !Float32VirtualArray::Is (source)
1163
1164
&& !Float64Array::Is (this ) && !Float64Array::Is (source)
1164
1165
&& !Float64VirtualArray::Is (this ) && !Float64VirtualArray::Is (source)))
Original file line number Diff line number Diff line change @@ -407,4 +407,9 @@ Below test fails with difference in space. Investigate the cause and re-enable t
407
407
<tags >typedarray</tags >
408
408
</default >
409
409
</test >
410
+ <test >
411
+ <default >
412
+ <files >typeofDetached.js</files >
413
+ </default >
414
+ </test >
410
415
</regress-exe >
Original file line number Diff line number Diff line change
1
+ //-------------------------------------------------------------------------------------------------------
2
+ // Copyright (C) Microsoft. All rights reserved.
3
+ // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4
+ //-------------------------------------------------------------------------------------------------------
5
+
6
+ const obj = { } ;
7
+ const f32 = new Float32Array ( ) ;
8
+ function foo ( ) {
9
+ return typeof f32 [ obj . missingprop & 1 ] ;
10
+ }
11
+ ArrayBuffer . detach ( f32 . buffer ) ;
12
+ for ( let i = 0 ; i < 1000 ; ++ i ) {
13
+ foo ( ) ;
14
+ }
15
+ foo ( ) ;
16
+ console . log ( "pass" ) ;
You can’t perform that action at this time.
0 commit comments