From 6d98cc6eba40e3718e141e51139be8d95eb950d5 Mon Sep 17 00:00:00 2001 From: xiaofan Date: Mon, 6 Apr 2020 00:34:59 +0800 Subject: [PATCH] fix AsyncClient::connect memory leak Signed-off-by: xiaofan --- src/ESPAsyncTCP.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ESPAsyncTCP.cpp b/src/ESPAsyncTCP.cpp index 7a9fdc7..74a2b7a 100644 --- a/src/ESPAsyncTCP.cpp +++ b/src/ESPAsyncTCP.cpp @@ -265,6 +265,9 @@ bool AsyncClient::connect(IPAddress ip, uint16_t port){ tcp_arg(pcb, this); tcp_err(pcb, &_s_error); size_t err = tcp_connect(pcb, &addr, port,(tcp_connected_fn)&_s_connected); + if (err != ERR_OK){ + tcp_close(pcb); + } return (ERR_OK == err); }