From 328523f5e3289de193e04aaf4bf13f9672078fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20P=2E=20Sch=C3=BCmann?= <33527753+Schuemi@users.noreply.github.com> Date: Wed, 25 Jul 2018 12:56:41 +0200 Subject: [PATCH] Memory leak (#1672) When a package of size 0 arrives, "buf" is created, but never released. (Sorry, that was my mistake in the last patch) --- libraries/WiFi/src/WiFiUdp.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/WiFi/src/WiFiUdp.cpp b/libraries/WiFi/src/WiFiUdp.cpp index acc7a183..476b5a4a 100644 --- a/libraries/WiFi/src/WiFiUdp.cpp +++ b/libraries/WiFi/src/WiFiUdp.cpp @@ -221,9 +221,10 @@ int WiFiUDP::parsePacket(){ } remote_ip = IPAddress(si_other.sin_addr.s_addr); remote_port = ntohs(si_other.sin_port); - if (len == 0) return 0; - 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; }