From 1b3d7630151322bdbd3d076d1cfd6c44a32af1ab Mon Sep 17 00:00:00 2001 From: "Robin C. Ladiges" Date: Thu, 16 May 2024 21:46:05 +0200 Subject: [PATCH] fix: memory leak if send queue is full --- source/server/SocketClient.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/server/SocketClient.cpp b/source/server/SocketClient.cpp index ecadc36..4980415 100644 --- a/source/server/SocketClient.cpp +++ b/source/server/SocketClient.cpp @@ -541,10 +541,9 @@ void SocketClient::recvFunc() { } bool SocketClient::queuePacket(Packet* packet) { - if (socket_log_state == SOCKET_LOG_CONNECTED && mPacketQueueOpen) { - mSendQueue.push((s64)packet, - sead::MessageQueue::BlockType::NonBlocking); // as this is non-blocking, it - // will always return true. + if (socket_log_state == SOCKET_LOG_CONNECTED && mPacketQueueOpen && !mSendQueue.isFull()) { + // as this is non-blocking, it will always return true. + mSendQueue.push((s64)packet, sead::MessageQueue::BlockType::NonBlocking); return true; } else { mHeap->free(packet);