From 05631c843fa24ac4e70dca96ca46ef23ebdb8469 Mon Sep 17 00:00:00 2001 From: dmex Date: Mon, 21 Nov 2011 00:03:16 +0000 Subject: [PATCH] Updater: fixed string leak, fixed invalid handle for Retry case git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4890 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- 2.x/trunk/plugins/Updater/updater.c | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/2.x/trunk/plugins/Updater/updater.c b/2.x/trunk/plugins/Updater/updater.c index f53b90172..60b257da7 100644 --- a/2.x/trunk/plugins/Updater/updater.c +++ b/2.x/trunk/plugins/Updater/updater.c @@ -188,22 +188,11 @@ static void __cdecl WorkerThreadStart( return; } + PhDereferenceObject(LocalFileNameString); + LocalFilePathString = PhConcatStrings2(lpTempPathBuffer, sText->Buffer); PhDereferenceObject(sText); - - // Create output file - if ((TempFileHandle = CreateFile( - LocalFilePathString->Buffer, - GENERIC_WRITE, - FILE_SHARE_WRITE, - 0, // handle cannot be inherited - CREATE_ALWAYS, // if file exists, delete it - FILE_ATTRIBUTE_NORMAL, - 0)) == INVALID_HANDLE_VALUE) - { - LogEvent(hwndDlg, PhFormatString(L"CreateFile failed (%d)", GetLastError())); - } } PhUpdaterState = Downloading; @@ -902,6 +891,21 @@ VOID RunAction( Edit_Visible(GetDlgItem(hwndDlg, IDC_SPEEDTEXT), TRUE); Edit_Visible(GetDlgItem(hwndDlg, IDC_RTIMETEXT), TRUE); + DisposeFileHandles(); + + // Create output file + if ((TempFileHandle = CreateFile( + LocalFilePathString->Buffer, + GENERIC_WRITE, + FILE_SHARE_WRITE, + 0, // handle cannot be inherited + CREATE_ALWAYS, // if file exists, delete it + FILE_ATTRIBUTE_NORMAL, + 0)) == INVALID_HANDLE_VALUE) + { + LogEvent(hwndDlg, PhFormatString(L"CreateFile failed (%d)", GetLastError())); + } + // Star our Downloader thread _beginthread(DownloadWorkerThreadStart, 0, hwndDlg); }