From 02a9f065c5df58cc9dbbc947d7367c80bd1d1ca5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 23 Apr 2014 07:55:10 -0700 Subject: 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 --- tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp') 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); -- cgit v1.2.3