aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4typedarray.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-08-12 15:45:26 +0200
committerLars Knoll <lars.knoll@qt.io>2018-08-23 08:13:25 +0000
commit1abbc4aa2c3f8f0b76ae524785711dc73fd69120 (patch)
tree49e26bc7cf71709472b3ec72efc80b0a1214c808 /src/qml/jsruntime/qv4typedarray.cpp
parentc497fbbef4637f602ca897cf18a184b32d374dac (diff)
Fix a couple of test failures for detached buffers
Change-Id: I76308d4699f212758274b75ea1328e7f6a6c6be8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4typedarray.cpp')
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index 21b90ad851..625d0f9961 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -450,6 +450,9 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_get_byteLength(const Function
if (!v)
return v4->throwTypeError();
+ if (v->d()->buffer->isDetachedBuffer())
+ return Encode(0);
+
return Encode(v->d()->byteLength);
}
@@ -460,6 +463,9 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_get_byteOffset(const Function
if (!v)
return v4->throwTypeError();
+ if (v->d()->buffer->isDetachedBuffer())
+ return Encode(0);
+
return Encode(v->d()->byteOffset);
}
@@ -470,17 +476,20 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_get_length(const FunctionObje
if (!v)
return v4->throwTypeError();
+ if (v->d()->buffer->isDetachedBuffer())
+ return Encode(0);
+
return Encode(v->d()->byteLength/v->d()->type->bytesPerElement);
}
ReturnedValue IntrinsicTypedArrayPrototype::method_entries(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
Scope scope(b);
- Scoped<TypedArray> O(scope, thisObject);
- if (!O)
- THROW_TYPE_ERROR();
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
- Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(O));
+ Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(v));
ao->d()->iterationKind = IteratorKind::KeyValueIteratorKind;
return ao->asReturnedValue();
}
@@ -488,11 +497,11 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_entries(const FunctionObject
ReturnedValue IntrinsicTypedArrayPrototype::method_keys(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
Scope scope(b);
- Scoped<TypedArray> O(scope, thisObject);
- if (!O)
- THROW_TYPE_ERROR();
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
- Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(O));
+ Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(v));
ao->d()->iterationKind = IteratorKind::KeyIteratorKind;
return ao->asReturnedValue();
}
@@ -500,11 +509,11 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_keys(const FunctionObject *b,
ReturnedValue IntrinsicTypedArrayPrototype::method_values(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
Scope scope(b);
- Scoped<TypedArray> O(scope, thisObject);
- if (!O)
- THROW_TYPE_ERROR();
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
- Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(O));
+ Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(v));
ao->d()->iterationKind = IteratorKind::ValueIteratorKind;
return ao->asReturnedValue();
}