summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qvector
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2011-10-03 15:21:02 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-04 11:21:25 +0200
commit992a37234c5ec7494fc2f24217d36400f6c1630a (patch)
treee3bf0adbcb0dfa81ef950de7012d7e078d434bf1 /tests/auto/corelib/tools/qvector
parent22948130e878903bd9b98b8c031bce7dc07d7a95 (diff)
Don't crash by modifying read-only shared_null
Functions that modify the d-pointer must detach or otherwise take measures to not modify the const, read-only shared_null. The setSharable(bool) function takes care to detach when setting sharable to false, but should avoid setting the sharable data member unless d is not the shared null. Similarly, QMap<Key, T>::setInsertInOrder() needs to detach if it is shared with the shared_null (the logic has been updated to be the same as setSharable()). Change-Id: Ida5cb9818b86695f1b9f0264418b955c56424898 Reviewed-on: http://codereview.qt-project.org/5929 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qvector')
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index 4cc2bc481a..2b615bc28c 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -92,6 +92,8 @@ private slots:
void QTBUG11763_data();
void QTBUG11763();
void initializeList();
+
+ void const_shared_null();
};
void tst_QVector::constructors() const
@@ -940,5 +942,16 @@ void tst_QVector::initializeList()
#endif
}
+void tst_QVector::const_shared_null()
+{
+ QVector<int> v1;
+ v1.setSharable(false);
+ QVERIFY(v1.isDetached());
+
+ QVector<int> v2;
+ v2.setSharable(true);
+ QVERIFY(!v2.isDetached());
+}
+
QTEST_APPLESS_MAIN(tst_QVector)
#include "tst_qvector.moc"