summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-04-23 07:55:10 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-24 10:37:21 +0200
commit02a9f065c5df58cc9dbbc947d7367c80bd1d1ca5 (patch)
treead6e51ece23d6094fafc19d5b158bb90e10ee2c5
parentf9d7f85079f0ecf8f36399eeccc42bad8f1d3306 (diff)
Autotest: fix use of dangling pointer
The "data" pointer became technically dangling after line 1866 did copy = data; as copy was the last reference to the original data. That made the pointer address available to be reused by the system malloc(), which sometimes happened, causing the unit test to fail. Discussed-on: http://lists.qt-project.org/pipermail/development/2014-April/016588.html Change-Id: Ifa6a27bd53a6e60392b77a6609f2d47148695211 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index 6e183f3212..cdcbd19ae8 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -1863,7 +1863,7 @@ void tst_QByteArray::reserve()
QCOMPARE(qba.capacity(), capacity);
QCOMPARE(copy.capacity(), capacity);
- copy = qba;
+ qba = copy;
qba.reserve(capacity * 2);
QCOMPARE(qba.size(), capacity);
QCOMPARE(qba.capacity(), capacity * 2);