QAbstractSocket: fix a possible crash in waitForReadyRead()
waitForConnected() could return 'true' even when the socket was disconnected. Change-Id: I99d9c9730f4e9b6c8a54696eb92c24c3ef36d261 Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>bb10
parent
359546b069
commit
0db793fe41
|
|
@ -2149,8 +2149,10 @@ bool QAbstractSocket::waitForReadyRead(int msecs)
|
|||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(d->socketEngine);
|
||||
do {
|
||||
if (state() != ConnectedState)
|
||||
return false;
|
||||
|
||||
bool readyToRead = false;
|
||||
bool readyToWrite = false;
|
||||
if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(),
|
||||
|
|
@ -2172,9 +2174,6 @@ bool QAbstractSocket::waitForReadyRead(int msecs)
|
|||
|
||||
if (readyToWrite)
|
||||
d->canWriteNotification();
|
||||
|
||||
if (state() != ConnectedState)
|
||||
return false;
|
||||
} while (msecs == -1 || qt_subtract_from_timeout(msecs, stopWatch.elapsed()) > 0);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue