aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arraydata.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-09-09 15:45:18 +0200
committerUlf Hermann <ulf.hermann@qt.io>2025-09-12 22:28:51 +0200
commite0f65fe66f0cc17eaf4c6c41d1b2f65ab2737e3c (patch)
tree3bb8b5e9cc62fd6564d8f536d2e4cfbf17d6aeeb /src/qml/jsruntime/qv4arraydata.cpp
parent5a664f08367095b1af9198e3678663f4e7c1094a (diff)
QtQml: Empty SimpleArrayData vacant space when truncating
Without this we effectively soft-leak the contents of any SimpleArrayData whenever we truncate it. Only when the array was either completely dropped or re-filled would the extra objects be reclaimed. Task-number: QTBUG-139025 Pick-to: 6.10 6.9 6.8 Change-Id: I88e9dc3ea8ec57c1de71b7b5417ebcfbaa75bb61 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4arraydata.cpp')
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 724f6fbfa3..f691fe6beb 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -264,14 +264,19 @@ uint SimpleArrayData::truncate(Object *o, uint newLen)
return newLen;
if (!dd->attrs) {
+ for (uint i = newLen; i < dd->values.size; ++i)
+ dd->setData(dd->internalClass->engine, i, Value::emptyValue());
dd->values.size = newLen;
return newLen;
}
while (dd->values.size > newLen) {
- if (!dd->data(dd->values.size - 1).isEmpty() && !dd->attrs[dd->values.size - 1].isConfigurable())
+ const uint lastIndex = dd->values.size - 1;
+ if (!dd->data(lastIndex).isEmpty() && !dd->attrs[lastIndex].isConfigurable())
return dd->values.size;
- --dd->values.size;
+
+ dd->setData(dd->internalClass->engine, lastIndex, Value::emptyValue());
+ dd->values.size = lastIndex;
}
return dd->values.size;
}