Skip to content

Commit

Permalink
Fix AsyncUDP receive memory leak (#2607)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jweigelt authored and me-no-dev committed Apr 11, 2019
1 parent 6744565 commit a87b2ec
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions libraries/AsyncUDP/src/AsyncUDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit a87b2ec

Please sign in to comment.