diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-09-01 20:23:36 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-09-04 18:25:28 +0000 |
commit | c71448dc97778b48824f081749fe4c270a34446f (patch) | |
tree | cae5ad0714a6be5cdf91f0d3f110943fb28702ca /src/qml/jsruntime/qv4arraybuffer.cpp | |
parent | d8da213ed5ff7ee8fddc3d2e40c20b6e51941ae9 (diff) |
Fix subclassing of ArrayBuffer and TypedArrays
Change-Id: I481974c224f7fdb4df6b641e8dd550add96b4c08
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4arraybuffer.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4arraybuffer.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index 9b5a983fdf..e74503e9d3 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -85,7 +85,7 @@ ReturnedValue SharedArrayBufferCtor::virtualCall(const FunctionObject *f, const } -ReturnedValue ArrayBufferCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *) +ReturnedValue ArrayBufferCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget) { ExecutionEngine *v4 = f->engine(); Scope scope(v4); @@ -99,6 +99,12 @@ ReturnedValue ArrayBufferCtor::virtualCallAsConstructor(const FunctionObject *f, return v4->throwRangeError(QLatin1String("ArrayBuffer constructor: invalid length")); Scoped<ArrayBuffer> a(scope, v4->newArrayBuffer(len)); + if (newTarget->heapObject() != f->heapObject() && newTarget->isFunctionObject()) { + const FunctionObject *nt = static_cast<const FunctionObject *>(newTarget); + ScopedObject o(scope, nt->protoProperty()); + if (o) + a->setPrototypeOf(o); + } if (scope.engine->hasException) return Encode::undefined(); |