From 63a8d79553443e9048f31d53d4111f93d819ff75 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 3 Nov 2017 06:44:40 -0600 Subject: [PATCH] net/inet: Fix a memory leak when closing a TCP socket. --- net/inet/inet_close.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/inet/inet_close.c b/net/inet/inet_close.c index 66b798a305..bfb19d12de 100644 --- a/net/inet/inet_close.c +++ b/net/inet/inet_close.c @@ -348,7 +348,11 @@ static inline int tcp_close_disconnect(FAR struct socket *psock) * release it now. */ - psock->s_sndcb = NULL; + if (psock->s_sndcb != NULL) + { + tcp_callback_free(conn, psock->s_sndcb); + psock->s_sndcb = NULL; + } #endif /* Check for the case where the host beat us and disconnected first */