Remove manual malloc and free in Win32 Platform::GetSteamPaths

This commit is contained in:
mix committed 2026-05-02 15:32:08 +01:00
1 parent 7595d6702b
commit f4336f1feb
1 file changed
+4 -6
+4 -6
View File
@@ -741,10 +741,8 @@ namespace OpenRCT2::Platform
SteamPaths GetSteamPaths()
{
wchar_t* wSteamPath;
HKEY hKey;
DWORD type, size;
LRESULT result;
if (RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Valve\\Steam", &hKey) != ERROR_SUCCESS)
return {};
@@ -757,13 +755,13 @@ namespace OpenRCT2::Platform
}
std::string outPath = "";
wSteamPath = reinterpret_cast<wchar_t*>(malloc(size));
result = RegQueryValueExW(hKey, L"SteamPath", nullptr, &type, reinterpret_cast<LPBYTE>(wSteamPath), &size);
const auto steamPath = std::make_unique_for_overwrite<wchar_t[]>(size);
const auto result = RegQueryValueExW(
hKey, L"SteamPath", nullptr, &type, reinterpret_cast<LPBYTE>(steamPath.get()), &size);
if (result == ERROR_SUCCESS)
{
outPath = String::toUtf8(wSteamPath);
outPath = String::toUtf8(steamPath.get());
}
free(wSteamPath);
RegCloseKey(hKey);
SteamPaths ret = {};