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
This commit is contained in:
dmex
2011-11-21 00:03:16 +00:00
parent 14ef4c81e1
commit 05631c843f
+17 -13
View File
@@ -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);
}