From 906bab9fdef7c28ba5eef5bf14aeaaa9448ab0b5 Mon Sep 17 00:00:00 2001 From: Andrea Gilardoni Date: Tue, 23 Jan 2024 17:30:46 +0100 Subject: [PATCH] deleting pbuf when partially consumed --- libraries/lwIpWrapper/src/lwipClient.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/lwIpWrapper/src/lwipClient.cpp b/libraries/lwIpWrapper/src/lwipClient.cpp index 02103ba1..de08121d 100644 --- a/libraries/lwIpWrapper/src/lwipClient.cpp +++ b/libraries/lwIpWrapper/src/lwipClient.cpp @@ -363,9 +363,12 @@ void lwipClient::stop() { // reset all the other variables in this class - // if(tcp->p != nullptr) { - // pbuf_free(tcp->p); // FIXME it happens that a pbuf, with ref == 0 is added for some reason - // } + if(this->tcp_info->pbuf_head != nullptr) { + pbuf_free(this->tcp_info->pbuf_head); // FIXME it happens that a pbuf, with ref == 0 is added for some reason + this->tcp_info->pbuf_head = nullptr; + } + this->tcp_info->pbuf_offset = 0; + if(this->tcp_info->server != nullptr) { // need to first make the server point to nullptr, then remove the client, can cause infinite recursion auto server = this->tcp_info->server;