From a40780e567ed59b034753f2ceedbab1b4d2933bd Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 9 Oct 2018 21:40:24 +0200 Subject: [PATCH] [Utils] Fix memory-leaking and corrupting functions --- src/Utils/String.cpp | 18 ------------------ src/Utils/String.hpp | 2 -- src/Utils/WebIO.cpp | 5 +++-- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index 568629b1..9fe76eba 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -207,23 +207,5 @@ namespace Utils return retval; } #endif - - // Generates a UUID and returns the string representation of it - std::string GenerateUUIDString() - { - // Generate UUID data - UUID uuid; - if (!UuidCreate(&uuid)) - { - // Convert to string representation - char* strdata = nullptr; - if (!UuidToStringA(&uuid, reinterpret_cast(&strdata))) - { - return std::string(strdata); - } - } - - return ""; - } } } diff --git a/src/Utils/String.hpp b/src/Utils/String.hpp index bf89e39f..3f20d394 100644 --- a/src/Utils/String.hpp +++ b/src/Utils/String.hpp @@ -96,7 +96,5 @@ namespace Utils std::string EncodeBase64(const std::string& input); std::string EncodeBase128(const std::string& input); - - std::string GenerateUUIDString(); } } diff --git a/src/Utils/WebIO.cpp b/src/Utils/WebIO.cpp index 3b3dd25e..bf9613e4 100644 --- a/src/Utils/WebIO.cpp +++ b/src/Utils/WebIO.cpp @@ -57,11 +57,12 @@ namespace Utils } PARSEDURLA pURL; + ZeroMemory(&pURL, sizeof(pURL)); pURL.cbSize = sizeof(pURL); ParseURLA(_url.data(), &pURL); // Parse protocol - if (pURL.cchProtocol && pURL.cchProtocol != 0xCCCCCCCC && pURL.pszProtocol) + if (pURL.cchProtocol && pURL.pszProtocol) { for (UINT i = 0; i < pURL.cchProtocol; ++i) { @@ -77,7 +78,7 @@ namespace Utils // Parse suffix std::string server; - if (pURL.cchSuffix && pURL.cchSuffix != 0xCCCCCCCC && pURL.pszSuffix) + if (pURL.cchSuffix && pURL.pszSuffix) { server.append(pURL.pszSuffix, pURL.cchSuffix); }