From c894ce30c412ed77ae02d08c4f4954296152171d Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 10 Jul 2019 13:16:07 +0200 Subject: [PATCH] Fix socket packet reading. --- Telegram/SourceFiles/mtproto/connection_tcp.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Telegram/SourceFiles/mtproto/connection_tcp.cpp b/Telegram/SourceFiles/mtproto/connection_tcp.cpp index 7d22ea1d3..5a7fbfe8e 100644 --- a/Telegram/SourceFiles/mtproto/connection_tcp.cpp +++ b/Telegram/SourceFiles/mtproto/connection_tcp.cpp @@ -307,6 +307,10 @@ void TcpConnection::socketRead() { _leftBytes -= readCount; if (!_leftBytes) { socketPacket(full.subspan(0, _readBytes)); + if (!_socket || !_socket->isConnected()) { + return; + } + _usingLargeBuffer = false; _largeBuffer.clear(); _offsetBytes = _readBytes = 0; @@ -331,6 +335,10 @@ void TcpConnection::socketRead() { return; } else if (available.size() >= packetSize) { socketPacket(available.subspan(0, packetSize)); + if (!_socket || !_socket->isConnected()) { + return; + } + available = available.subspan(packetSize); _offsetBytes += packetSize; _readBytes -= packetSize;