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.
This commit is contained in:
parent
6744565257
commit
a87b2ec690
@ -682,9 +682,8 @@ void AsyncUDP::_recv(udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t po
|
|||||||
if(_handler) {
|
if(_handler) {
|
||||||
AsyncUDPPacket packet(this, this_pb, addr, port, netif);
|
AsyncUDPPacket packet(this, this_pb, addr, port, netif);
|
||||||
_handler(packet);
|
_handler(packet);
|
||||||
} else {
|
|
||||||
pbuf_free(this_pb);
|
|
||||||
}
|
}
|
||||||
|
pbuf_free(this_pb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user