aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-08-29 15:23:22 +0200
committerLars Knoll <lars.knoll@qt.io>2018-08-29 18:11:05 +0000
commitddb05b5fa2f93239c1ab58b270a8840053ddd39f (patch)
treeeb259058afb0f656bd3d5c8a3fc48538a0ad9e1b /src/qml/jsruntime/qv4runtime.cpp
parentcc81e068ee6647dddf404510097060d38801f758 (diff)
Throw a type error if the super class is not a constructor
Change-Id: I1cf83c73ea1b628f44845e1b9ea324d3e069c344 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index edaa0a8e63..3317003ea4 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -917,11 +917,12 @@ ReturnedValue Runtime::method_loadSuperConstructor(ExecutionEngine *engine, cons
return engine->throwReferenceError(QStringLiteral("super() already called."), QString(), 0, 0); // ### fix line number
}
const FunctionObject *f = t.as<FunctionObject>();
- if (!f || !f->isConstructor()) {
- engine->throwTypeError();
- return Encode::undefined();
- }
- return static_cast<const Object &>(t).getPrototypeOf()->asReturnedValue();
+ if (!f)
+ return engine->throwTypeError();
+ Heap::Object *c = static_cast<const Object &>(t).getPrototypeOf();
+ if (!c->vtable()->isFunctionObject || !static_cast<Heap::FunctionObject *>(c)->isConstructor())
+ return engine->throwTypeError();
+ return c->asReturnedValue();
}