Skip to content

Commit

Permalink
Backport fix for possible memleak when receiving zero size UDP packets.
Browse files Browse the repository at this point in the history
  • Loading branch information
everslick committed Sep 15, 2021
1 parent 2c348e2 commit 7313df6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libraries/WiFi/src/WiFiUdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ int WiFiUDP::parsePacket(){
}
remote_ip = IPAddress(si_other.sin_addr.s_addr);
remote_port = ntohs(si_other.sin_port);
rx_buffer = new cbuf(len);
rx_buffer->write(buf, len);
if (len > 0) {
rx_buffer = new cbuf(len);
rx_buffer->write(buf, len);
}
delete[] buf;
return len;
}
Expand Down

0 comments on commit 7313df6

Please sign in to comment.