From a87b2ec69054ce43a48bd042599b4185267ebc1d Mon Sep 17 00:00:00 2001 From: Jan Weigelt Date: Thu, 11 Apr 2019 16:49:35 +0200 Subject: [PATCH] Fix AsyncUDP receive memory leak (#2607) If _handler is set, pbuf_free is not called. ~AsyncUDPPacket() calls pbuf_free once but only after calling pbuf_ref in it's constructor. The refcount never reaches zero and the memory allocated for pbuf is never released. --- libraries/AsyncUDP/src/AsyncUDP.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/AsyncUDP/src/AsyncUDP.cpp b/libraries/AsyncUDP/src/AsyncUDP.cpp index 5faf4393..48186051 100644 --- a/libraries/AsyncUDP/src/AsyncUDP.cpp +++ b/libraries/AsyncUDP/src/AsyncUDP.cpp @@ -682,9 +682,8 @@ void AsyncUDP::_recv(udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t po if(_handler) { AsyncUDPPacket packet(this, this_pb, addr, port, netif); _handler(packet); - } else { - pbuf_free(this_pb); } + pbuf_free(this_pb); } }