summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2015-10-10 19:49:41 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2015-10-13 05:20:08 +0000
commit0872156559dd290e8e940d22a89cb95a46ef0cf6 (patch)
tree2d35e795ff080ed1e44d9e713bb7abc3a8d02555 /tests
parenta2f6ece27f95eb7cb9940af6ba734d4ba52bf4cb (diff)
QAbstractSocket: fix writing to socket in HostLookup state
After calling connectToHost(), the socket enters HostLookup state. At this stage, the socket engine was not created yet, and writing to the socket should result in either data buffering or an error. So, add a check for d->socketEngine to prevent a crash on unbuffered sockets. Task-number: QTBUG-48356 Change-Id: I15ea9ce7de97ce6d7e13e358eca5350745b556bb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
index a4695955af..6f96e6d6f5 100644
--- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -117,6 +117,7 @@ private slots:
void readyRead();
void readyReadForEmptyDatagram();
void asyncReadDatagram();
+ void writeInHostLookupState();
protected slots:
void empty_readyReadSlot();
@@ -1725,5 +1726,17 @@ void tst_QUdpSocket::asyncReadDatagram()
delete m_asyncReceiver;
}
+void tst_QUdpSocket::writeInHostLookupState()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ QUdpSocket socket;
+ socket.connectToHost("nosuchserver.qt-project.org", 80);
+ QCOMPARE(socket.state(), QUdpSocket::HostLookupState);
+ QVERIFY(!socket.putChar('0'));
+}
+
QTEST_MAIN(tst_QUdpSocket)
#include "tst_qudpsocket.moc"