aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-08-01 22:19:57 +0200
committerLars Knoll <lars.knoll@qt.io>2018-08-02 20:25:24 +0000
commit2291588304b6c057ad8fe0551aa76f33a4055917 (patch)
treef1a2e0fae9d31531744c5a0fc6093736cdeb8f7a /src/qml/jsruntime/qv4runtime.cpp
parent245cb6b6a3e5a04dc43a3c4ce15831f68309e97f (diff)
Fix writing to properties of primitive data
In strict mode, this should throw a type error and not do an implicit toObject conversion. Change-Id: I7b8cdf1125978b9d9a047d9da84f23b547cb4a75 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 7839db8e01..abfc3e730b 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -579,7 +579,14 @@ void Runtime::method_storeProperty(ExecutionEngine *engine, const Value &object,
Scope scope(engine);
QV4::Function *v4Function = engine->currentStackFrame->v4Function;
ScopedString name(scope, v4Function->compilationUnit->runtimeStrings[nameIndex]);
- ScopedObject o(scope, object.toObject(engine));
+ ScopedObject o(scope, object);
+ if (!o) {
+ if (v4Function->isStrict()) {
+ engine->throwTypeError();
+ return;
+ }
+ o = object.toObject(engine);
+ }
if ((!o || !o->put(name, value)) && v4Function->isStrict())
engine->throwTypeError();
}
@@ -664,7 +671,15 @@ ReturnedValue Runtime::method_loadElement(ExecutionEngine *engine, const Value &
static Q_NEVER_INLINE bool setElementFallback(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)
{
Scope scope(engine);
- ScopedObject o(scope, object.toObject(engine));
+ ScopedObject o(scope, object);
+ if (!o) {
+ if (engine->currentStackFrame->v4Function->isStrict()) {
+ engine->throwTypeError();
+ return false;
+ }
+
+ o = object.toObject(engine);
+ }
if (engine->hasException)
return false;