From 65d453049ab666b026790be8da8bd22e469a87eb Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 6 Mar 2017 21:57:47 -0800 Subject: [PATCH] UI/updater: Fix temp files being created and not deleted The GetTempPath and GetTempFileName functions weren't being used correctly, GetTempFileName always create a temporary file, and was creating a temporary file in the root directory of the hard drive unintentionally. --- UI/win-update/updater/updater.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UI/win-update/updater/updater.cpp b/UI/win-update/updater/updater.cpp index 5ada4618d..65339b169 100644 --- a/UI/win-update/updater/updater.cpp +++ b/UI/win-update/updater/updater.cpp @@ -987,18 +987,18 @@ static bool Update(wchar_t *cmdLine) StringCbPrintf(manifestPath, sizeof(manifestPath), L"%s\\updates\\manifest.json", lpAppDataPath); - if (!GetTempPathW(_countof(tempPath), tempPath)) { + if (!GetTempPathW(_countof(tempDirName), tempDirName)) { Status(L"Update failed: Failed to get temp path: %ld", GetLastError()); return false; } - if (!GetTempFileNameW(tempDirName, L"obs-studio", 0, tempDirName)) { + if (!GetTempFileNameW(tempDirName, L"obs-studio", 0, tempPath)) { Status(L"Update failed: Failed to create temp dir name: %ld", GetLastError()); return false; } - StringCbCat(tempPath, sizeof(tempPath), tempDirName); + DeleteFile(tempPath); CreateDirectory(tempPath, nullptr); /* ------------------------------------- *