From b7535252c28064d293a0e5ce49b8a4b0e254ec4c Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 3 Feb 2023 21:56:35 -0800 Subject: [PATCH] [ntcore] Don't leak buffers in rare WS shutdown case (#5046) If the request called the callback after the WebSocket had been destroyed, the buffers were leaked. --- ntcore/src/main/native/cpp/net/WebSocketConnection.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp b/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp index d3d192fe0a..9a7aa0dfe7 100644 --- a/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp +++ b/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp @@ -50,6 +50,10 @@ void WebSocketConnection::Flush() { if (self->m_sendsActive > 0) { --self->m_sendsActive; } + } else { + for (auto&& buf : bufs) { + buf.Deallocate(); + } } }); m_frames.clear();