diff options
author | Jesus Fernandez <jesus.fernandez@theqtcompany.com> | 2016-05-12 16:20:47 +0200 |
---|---|---|
committer | Jesus Fernandez <jesus.fernandez@theqtcompany.com> | 2016-05-13 03:58:06 +0000 |
commit | 2ac3fab45f1388591b3d1b73b8419ba45d63f064 (patch) | |
tree | 77786912d11fbb8df4833d4a0c51a25f6937eaea | |
parent | 2852a8b87e3a8ed95b72d26b0e180b7fd4491cf3 (diff) |
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>
-rw-r--r-- | src/network/kernel/qauthenticator.cpp | 2 | ||||
-rw-r--r-- | tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 95994653e6..92d8779cab 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -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 diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp index 026a2a2722..90a6aa5811 100644 --- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp +++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp @@ -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" |