From 3fabecabc1feffdf80a082452f5847dbeab964f2 Mon Sep 17 00:00:00 2001 From: mix Date: Sat, 2 May 2026 12:51:47 +0100 Subject: [PATCH] Remove manual new/delete in Win32 Platform::GetEnvironmentVariable --- src/openrct2/platform/Platform.Win32.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index a7185bb4a6..d32560bbc3 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -70,10 +70,9 @@ namespace OpenRCT2::Platform } else { - auto wlvalue = new wchar_t[valueSize]; - GetEnvironmentVariableW(wname.c_str(), wlvalue, valueSize); - result = wlvalue; - delete[] wlvalue; + const auto buffer = std::make_unique_for_overwrite(valueSize); + GetEnvironmentVariableW(wname.c_str(), buffer.get(), valueSize); + result = buffer.get(); } return String::toUtf8(result); }