From 1bed4a256522fab123ffe9c42a5988f50ea0aa0b Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 2 Oct 2021 19:08:03 +0300 Subject: QLocalSocket/Win: add missing check to waitForBytesWritten() Calling pipeWriter->checkForWrite() can indirectly close the socket even if the bytesWritten() signal has not been sent. So, we need to make sure the handle is valid before checking pipe state in the reader. There is no harm in calling PeekNamedPipe() with an invalid handle, but the wrong call should be avoided. This patch amends b2c3b3e8fe0d8bdc88051d0120aaa8d5cf8acce0. Change-Id: I5d2ecbbbe0af817aac68ad6f1173b0ed9b324e98 Reviewed-by: Oswald Buddenhagen --- src/network/socket/qlocalsocket_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/network') diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 019829cc9c..b98dcb0dbc 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -582,7 +582,7 @@ bool QLocalSocket::waitForBytesWritten(int msecs) if (d->pipeWriter->checkForWrite()) return true; - if (poller.waitForClose) + if (poller.waitForClose && isValid()) d->pipeReader->checkPipeState(); d->pipeReader->checkForReadyRead(); -- cgit v1.2.3