From 97d9009500d84e25e93c661e28b0c0fa804d141c Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Fri, 2 Apr 2021 09:06:32 +0800 Subject: [PATCH] Utils: Win32: Fix API usage Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- utilities_win32.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utilities_win32.cpp b/utilities_win32.cpp index a8a9cee..7aa0535 100644 --- a/utilities_win32.cpp +++ b/utilities_win32.cpp @@ -563,10 +563,10 @@ QImage Utilities::getDesktopWallpaperImage(const int screen) qWarning() << "Failed to initialize COM."; } qDebug() << "Shell API failed. Using SystemParametersInfoW instead."; - LPWSTR wallpaperPath = nullptr; + const auto wallpaperPath = new WCHAR[MAX_PATH]; if (SystemParametersInfoW(SPI_GETDESKWALLPAPER, MAX_PATH, wallpaperPath, 0) != FALSE) { const QString _path = QString::fromWCharArray(wallpaperPath); - CoTaskMemFree(wallpaperPath); + delete [] wallpaperPath; return QImage(_path); } qWarning() << "SystemParametersInfoW failed. Reading from the registry instead.";