[Utils] Fix memory-leaking and corrupting functions

This commit is contained in:
momo5502 2018-10-09 21:40:24 +02:00
parent 617b549032
commit a40780e567
3 changed files with 3 additions and 22 deletions

View File

@ -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<RPC_CSTR*>(&strdata)))
{
return std::string(strdata);
}
}
return "";
}
}
}

View File

@ -96,7 +96,5 @@ namespace Utils
std::string EncodeBase64(const std::string& input);
std::string EncodeBase128(const std::string& input);
std::string GenerateUUIDString();
}
}

View File

@ -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);
}