Fixed crash in QAuthenticator::operator==

[ChangeLog][QtNetwork][QAuthenticator] Fixed crash when
comparing a initialized QAuthenticator with an uninitialized
QAuthenticator.

Task-number: QTBUG-53338
Change-Id: Ib8b732b9c65c02ee542885e5d6fe9bd1589a6b1a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
This commit is contained in:
Jesus Fernandez 2016-05-12 16:20:47 +02:00
parent 2852a8b87e
commit 2ac3fab45f
2 changed files with 18 additions and 0 deletions

View File

@ -193,6 +193,8 @@ bool QAuthenticator::operator==(const QAuthenticator &other) const
{
if (d == other.d)
return true;
if (!d || !other.d)
return false;
return d->user == other.d->user
&& d->password == other.d->password
&& d->realm == other.d->realm

View File

@ -52,6 +52,8 @@ private Q_SLOTS:
void ntlmAuth_data();
void ntlmAuth();
void equalityOperators();
};
tst_QAuthenticator::tst_QAuthenticator()
@ -152,6 +154,20 @@ void tst_QAuthenticator::ntlmAuth()
QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM "));
}
void tst_QAuthenticator::equalityOperators()
{
QAuthenticator s1, s2;
QVERIFY(s2 == s1);
QVERIFY(s1 == s2);
QVERIFY(!(s1 != s2));
QVERIFY(!(s2 != s1));
s1.setUser("User");
QVERIFY(!(s2 == s1));
QVERIFY(!(s1 == s2));
QVERIFY(s1 != s2);
QVERIFY(s2 != s1);
}
QTEST_MAIN(tst_QAuthenticator);
#include "tst_qauthenticator.moc"