From 80cc30df11ea2f871bf17ac4282e5544e957b91f Mon Sep 17 00:00:00 2001 From: Christopher Pascoe Date: Mon, 21 Nov 2016 19:07:42 -0800 Subject: [PATCH] Use tcp_close to destroy the TCP listening socket. It's an error to call tcp_poll() on a pcb that has been converted to a listening socket via tcp_listen(), with such calls causing memory corruption. Call tcp_close to destroy the socket instead in ~TcpServer, and NULL out tcp to suppress the call to tcp_poll in the base class (via ~TcpConnection()->TcpConnection::close()->tcp_poll()). --- sming/sming/network/TcpServer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sming/sming/network/TcpServer.cpp b/sming/sming/network/TcpServer.cpp index 63bbe4f..ecea12d 100644 --- a/sming/sming/network/TcpServer.cpp +++ b/sming/sming/network/TcpServer.cpp @@ -60,6 +60,8 @@ TcpServer::TcpServer(TcpClientDataDelegate clientReceiveDataHandler) TcpServer::~TcpServer() { + tcp_close(tcp); + tcp = NULL; } TcpConnection* TcpServer::createClient(tcp_pcb *clientTcp)