From 2472d3d800dc310f77fa5d038a82dc4f52d666ac Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 25 Feb 2011 11:03:39 +0100 Subject: QAbstractSocket: Check for socket state on Unbuffered reads In the Unbuffered QTcpSocket mode the read() call could go to the socket engine even though we are not connected right now. Reviewed-by: Peter Hartmann --- src/network/socket/qabstractsocket.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index e223358..2a942cc 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -2201,6 +2201,8 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize) return -1; // no socket engine is probably EOF if (!d->socketEngine->isValid()) return -1; // This is for unbuffered TCP when we already had been disconnected + if (d->state != QAbstractSocket::ConnectedState) + return -1; // This is for unbuffered TCP if we're not connected yet qint64 readBytes = d->socketEngine->read(data, maxSize); if (readBytes == -2) { // -2 from the engine means no bytes available (EAGAIN) so read more later -- cgit v0.12