diff options
| author | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-03-06 09:24:39 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-01-30 17:14:08 +0100 |
| commit | 642d531e42fb233709155f8c8feb7d429c48db38 (patch) | |
| tree | a9b4d9d7aaa05015190c7c8831c8836347c446ac /src/qml/jsruntime/qv4object.cpp | |
| parent | 524d260c5c135d193e06350e48357444ddb13ddb (diff) | |
setInternalClass: Correctly handle deleted properties
When an IC was rebuilt, we must not set members that were deleted,
otherwise we'll trigger an assertion. Since the nameMap has to match the
data we still allocate memory for such members and fill it with
undefined. This could be avoided with some deeper refactoring, but a
simple solution is to be preferred because this needs to be picked back
all the way to 6.2.
Pick-to: 6.7 6.6 6.5 6.2
Fixes: QTBUG-111729
Change-Id: I730d6b4634d989191434225600a08cf0208e72f8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index f96b8f724b..49d351da67 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -42,8 +42,11 @@ void Object::setInternalClass(Heap::InternalClass *ic) // Pick the members of the old IC that are still valid in the new IC. // Order them by index in memberData (or inline data). Scoped<MemberData> newMembers(scope, MemberData::allocate(scope.engine, ic->size)); - for (uint i = 0; i < ic->size; ++i) - newMembers->set(scope.engine, i, get(ic->nameMap.at(i))); + for (uint i = 0; i < ic->size; ++i) { + // Note that some members might have been deleted. The key may be invalid. + const PropertyKey key = ic->nameMap.at(i); + newMembers->set(scope.engine, i, key.isValid() ? get(key) : Encode::undefined()); + } p->internalClass.set(scope.engine, ic); const uint nInline = p->vtable()->nInlineProperties; |
