Fixes DNS Server Memory Leak when deleted (#6707)

This commit is contained in:
Rodrigo Garcia
2022-05-09 09:59:24 -03:00
committed by GitHub
parent 0b3f1a9fa9
commit 44beee2f2c
2 changed files with 17 additions and 0 deletions

View File

@ -20,6 +20,22 @@ DNSServer::DNSServer()
_port = 0;
}
DNSServer::~DNSServer()
{
if (_dnsHeader) {
free(_dnsHeader);
_dnsHeader = NULL;
}
if (_dnsQuestion) {
free(_dnsQuestion);
_dnsQuestion = NULL;
}
if (_buffer) {
free(_buffer);
_buffer = NULL;
}
}
bool DNSServer::start(const uint16_t &port, const String &domainName,
const IPAddress &resolvedIP)
{

View File

@ -76,6 +76,7 @@ class DNSServer
{
public:
DNSServer();
~DNSServer();
void processNextRequest();
void setErrorReplyCode(const DNSReplyCode &replyCode);
void setTTL(const uint32_t &ttl);