From f221db70406d54cb516d77ebaaf60be941740f18 Mon Sep 17 00:00:00 2001 From: Connection Refused Date: Mon, 4 Oct 2021 19:31:24 +0800 Subject: [PATCH] [Redirector] Optimize code --- Redirector/DNSHandler.cpp | 2 +- Redirector/EventHandler.cpp | 2 +- Redirector/IPEventHandler.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Redirector/DNSHandler.cpp b/Redirector/DNSHandler.cpp index 0b885da4..4147fcad 100644 --- a/Redirector/DNSHandler.cpp +++ b/Redirector/DNSHandler.cpp @@ -74,7 +74,7 @@ bool DNSHandler::IsDNS(PSOCKADDR_IN6 target) void DNSHandler::CreateHandler(ENDPOINT_ID id, PSOCKADDR_IN6 target, const char* packet, int length, PNF_UDP_OPTIONS options) { SOCKADDR_IN6 remote; - auto buffer = new char[length]; + auto buffer = new char[length](); auto option = (PNF_UDP_OPTIONS)new char[sizeof(NF_UDP_OPTIONS) + options->optionsLength]; memcpy(&remote, target, sizeof(SOCKADDR_IN6)); diff --git a/Redirector/EventHandler.cpp b/Redirector/EventHandler.cpp index d97110ce..acfe1706 100644 --- a/Redirector/EventHandler.cpp +++ b/Redirector/EventHandler.cpp @@ -309,7 +309,7 @@ void udpSend(ENDPOINT_ID id, const unsigned char* target, const char* buffer, in return; } - auto data = (PNF_UDP_OPTIONS)new char[sizeof(NF_UDP_OPTIONS) + options->optionsLength]; + auto data = (PNF_UDP_OPTIONS)new char[sizeof(NF_UDP_OPTIONS) + options->optionsLength](); memcpy(data, options, sizeof(NF_UDP_OPTIONS) + options->optionsLength - 1); thread(udpBeginReceive, id, udpConn, data).detach(); diff --git a/Redirector/IPEventHandler.cpp b/Redirector/IPEventHandler.cpp index 7d62ec5e..ea29a150 100644 --- a/Redirector/IPEventHandler.cpp +++ b/Redirector/IPEventHandler.cpp @@ -53,7 +53,7 @@ void ipSend(const char* buffer, int length, PNF_IP_PACKET_OPTIONS options) return; } - auto data = new BYTE[length]; + auto data = new BYTE[length](); memcpy(data, buffer, length); {