From 5b8a4ae35620d1f761c3fcee355a5a049376e1ba Mon Sep 17 00:00:00 2001 From: serek4 Date: Mon, 5 Feb 2024 13:20:31 +0100 Subject: [PATCH] fix AsyncClient::connect memory leak [pull request 138](https://github.com/me-no-dev/ESPAsyncTCP/pull/138) --- src/ESPAsyncTCP.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ESPAsyncTCP.cpp b/src/ESPAsyncTCP.cpp index 8a997fa..850c432 100644 --- a/src/ESPAsyncTCP.cpp +++ b/src/ESPAsyncTCP.cpp @@ -264,6 +264,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); }