From fd075b9b3f907d74841f5b3591ea97aa246295d3 Mon Sep 17 00:00:00 2001 From: Emin Fedar Date: Tue, 28 Sep 2021 15:52:47 +0300 Subject: [PATCH] Fix memory leak by removing tcpsocket after closing --- async-sockets/include/tcpsocket.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/async-sockets/include/tcpsocket.hpp b/async-sockets/include/tcpsocket.hpp index 66f9455..b008128 100644 --- a/async-sockets/include/tcpsocket.hpp +++ b/async-sockets/include/tcpsocket.hpp @@ -110,6 +110,9 @@ class TCPSocket : public BaseSocket socket->Close(); if(socket->onSocketClosed) socket->onSocketClosed(errno); + + if (socket != nullptr) + delete socket; } void setTimeout(int seconds)