From 64f02ebf05d88eaa8399a5cff85db5a605ede62e Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 31 Mar 2021 18:01:01 +0300 Subject: [PATCH] QLocalSocket/Win: fix possible UB in _q_pipeClosed() We must stop the pipe writer before closing the handle on which it operates. Pick-to: 5.15 6.0 6.1 Change-Id: I4765dd8393167fe2453653aba76a097b8ace8e3d Reviewed-by: Oswald Buddenhagen --- src/network/socket/qlocalsocket_win.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 41ec5a94d4..677b431265 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -260,13 +260,10 @@ void QLocalSocketPrivate::_q_pipeClosed() emit q->disconnected(); pipeReader->stop(); + delete pipeWriter; + pipeWriter = nullptr; destroyPipeHandles(); handle = INVALID_HANDLE_VALUE; - - if (pipeWriter) { - delete pipeWriter; - pipeWriter = 0; - } } qint64 QLocalSocket::bytesAvailable() const