summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2011-02-25 10:03:39 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2011-02-25 10:14:16 (GMT)
commit2472d3d800dc310f77fa5d038a82dc4f52d666ac (patch)
treedef86ad8b709367bd4c975f72422046fd5d56741 /src
parent447de44bcba933c7fe4af4c54897f4c21950fc66 (diff)
downloadQt-2472d3d800dc310f77fa5d038a82dc4f52d666ac.zip
Qt-2472d3d800dc310f77fa5d038a82dc4f52d666ac.tar.gz
Qt-2472d3d800dc310f77fa5d038a82dc4f52d666ac.tar.bz2
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
Diffstat (limited to 'src')
-rw-r--r--src/network/socket/qabstractsocket.cpp2
1 files changed, 2 insertions, 0 deletions
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