From 426c52af7a947d88ff6cbd559a65fe54930b9fb2 Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov Date: Wed, 24 Jul 2024 09:39:08 +0200 Subject: [PATCH 1/2] Fix memory leak reported by coverity. --- Sming/Components/Network/src/Network/DnsServer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Sming/Components/Network/src/Network/DnsServer.cpp b/Sming/Components/Network/src/Network/DnsServer.cpp index 5479e5e072..69a4ca07a6 100644 --- a/Sming/Components/Network/src/Network/DnsServer.cpp +++ b/Sming/Components/Network/src/Network/DnsServer.cpp @@ -85,6 +85,7 @@ void DnsServer::onReceive(pbuf* buf, IpAddress remoteIP, uint16_t remotePort) unsigned requestLen = pbuf_copy_partial(buf, buffer, buf->tot_len, 0); if(requestLen != buf->tot_len) { + delete[] buffer; return; } From 4f13d322e77c5c2c72797c79076ccbe4ba8c8930 Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov Date: Wed, 24 Jul 2024 10:26:15 +0200 Subject: [PATCH 2/2] Review recommendations. --- Sming/Components/Network/src/Network/DnsServer.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Sming/Components/Network/src/Network/DnsServer.cpp b/Sming/Components/Network/src/Network/DnsServer.cpp index 69a4ca07a6..3e8c8e24ad 100644 --- a/Sming/Components/Network/src/Network/DnsServer.cpp +++ b/Sming/Components/Network/src/Network/DnsServer.cpp @@ -84,10 +84,6 @@ void DnsServer::onReceive(pbuf* buf, IpAddress remoteIP, uint16_t remotePort) } unsigned requestLen = pbuf_copy_partial(buf, buffer, buf->tot_len, 0); - if(requestLen != buf->tot_len) { - delete[] buffer; - return; - } debug_hex(DBG, "< DNS", buffer, requestLen); @@ -98,8 +94,6 @@ void DnsServer::onReceive(pbuf* buf, IpAddress remoteIP, uint16_t remotePort) } delete[] buffer; - - UdpConnection::onReceive(buf, remoteIP, remotePort); } size_t DnsServer::processQuestion(char* buffer, size_t requestLen)