diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2022-11-03 17:09:29 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-11-07 15:49:10 +0100 |
| commit | 872e91612fd83de6dd1193014b5e2a0f5e8c30af (patch) | |
| tree | 98eb22f6203a5b8f81e4149f919cac0f553c202c /src/qml/jsruntime/qv4arrayobject.cpp | |
| parent | 0b7374fefa1abf08e956bc5d34008352144bd9ae (diff) | |
Replace CallElement with separate instructions
We need to do the subscript lookup before generating the arguments since
the arguments may change the array.
Fixes: QTBUG-106708
Change-Id: Ia3a0dd34c6ed8d39e86ad20911a632d691826322
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4arrayobject.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4arrayobject.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 46cdbf15d3..05e73d0295 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -342,6 +342,9 @@ ReturnedValue ArrayPrototype::method_toLocaleString(const FunctionObject *b, con ScopedValue v(scope); ScopedString s(scope); + ScopedPropertyKey tolocaleString(scope, scope.engine->id_toLocaleString()->toPropertyKey()); + Q_ASSERT(!scope.engine->hasException); + for (uint k = 0; k < len; ++k) { if (k) R += separator; @@ -349,7 +352,18 @@ ReturnedValue ArrayPrototype::method_toLocaleString(const FunctionObject *b, con v = instance->get(k); if (v->isNullOrUndefined()) continue; - v = Runtime::CallElement::call(scope.engine, v, *scope.engine->id_toLocaleString(), nullptr, 0); + + ScopedObject valueAsObject(scope, v->toObject(scope.engine)); + Q_ASSERT(valueAsObject); // null and undefined handled above + + ScopedFunctionObject function(scope, valueAsObject->get(tolocaleString)); + if (!function) + return scope.engine->throwTypeError(); + + v = function->call(valueAsObject, nullptr, 0); + if (scope.hasException()) + return Encode::undefined(); + s = v->toString(scope.engine); if (scope.hasException()) return Encode::undefined(); |
