Check against copying the husk left by a move

The copy-assign operator tests against other.d being NULL but the
copy-constructor didn't.  This can only matter if the value being
copied has been moved from, so we could probably replace with an
assertion in practice, but we should at least be consistent.

Amended test to check this case too; and verified new test crashes
without this fix.

Change-Id: I46872a677775944bbdf6a9112e719873e574ae60
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Edward Welbourne 2018-07-11 20:38:58 +02:00
parent a5d8f00b3b
commit 0b688e2955
2 changed files with 5 additions and 1 deletions

View File

@ -89,7 +89,8 @@ QCollator::QCollator(const QLocale &locale)
QCollator::QCollator(const QCollator &other)
: d(other.d)
{
d->ref.ref();
if (d)
d->ref.ref();
}
/*!

View File

@ -72,6 +72,9 @@ void tst_QCollator::moveSemantics()
QCOMPARE(c2.locale(), de_AT);
QVERIFY(dpointer_is_null(c1));
QCollator c3(c1);
QVERIFY(dpointer_is_null(c3));
c1 = std::move(c2);
QCOMPARE(c1.locale(), de_AT);
QVERIFY(dpointer_is_null(c2));