Skip to content

Commit a87b2ec

Browse files
jweigeltme-no-dev
authored andcommitted
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.
1 parent 6744565 commit a87b2ec

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Diff for: libraries/AsyncUDP/src/AsyncUDP.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,8 @@ void AsyncUDP::_recv(udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t po
682682
if(_handler) {
683683
AsyncUDPPacket packet(this, this_pb, addr, port, netif);
684684
_handler(packet);
685-
} else {
686-
pbuf_free(this_pb);
687685
}
686+
pbuf_free(this_pb);
688687
}
689688
}
690689

0 commit comments

Comments
 (0)