SetCompressorStats must zero terminate the buffer from EM_GETLINE!
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6560 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
9eb4035b08
commit
9152c24610
3 changed files with 13 additions and 18 deletions
|
@ -344,12 +344,10 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
|
|||
return TRUE;
|
||||
}
|
||||
else {
|
||||
int this_compressor=0;
|
||||
int i;
|
||||
int this_compressor=0, i;
|
||||
HANDLE hPrev, hThis;
|
||||
DWORD prevSize=0, thisSize=0;
|
||||
|
||||
|
||||
for(i=(int)COMPRESSOR_SCRIPT+2; i<(int)COMPRESSOR_BEST; i++) {
|
||||
if(!lstrcmpi(g_sdata.compressor_name,compressor_names[i])) {
|
||||
this_compressor = i;
|
||||
|
@ -359,14 +357,14 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
|
|||
|
||||
if(FileExists(temp_file_name)) {
|
||||
hPrev = CreateFile(temp_file_name,GENERIC_READ, FILE_SHARE_READ,
|
||||
NULL, OPEN_EXISTING, (DWORD)NULL, NULL);
|
||||
NULL, OPEN_EXISTING, 0, NULL);
|
||||
if(hPrev != INVALID_HANDLE_VALUE) {
|
||||
prevSize = GetFileSize(hPrev, 0);
|
||||
CloseHandle(hPrev);
|
||||
|
||||
if(prevSize != INVALID_FILE_SIZE) {
|
||||
hThis = CreateFile(g_sdata.output_exe,GENERIC_READ, FILE_SHARE_READ,
|
||||
NULL, OPEN_EXISTING, (DWORD)NULL, NULL);
|
||||
NULL, OPEN_EXISTING, 0, NULL);
|
||||
if(hThis != INVALID_HANDLE_VALUE) {
|
||||
thisSize = GetFileSize(hThis, 0);
|
||||
CloseHandle(hThis);
|
||||
|
@ -763,7 +761,7 @@ DWORD WINAPI MakeNSISProc(LPVOID TreadParam) {
|
|||
PostMessage(g_sdata.hwnd, WM_MAKENSIS_PROCESSCOMPLETE, 0, 0);
|
||||
return 1;
|
||||
}
|
||||
CloseHandle(newstdout); // close this handle (duplicated in subprocess) now so we get ERROR_BROKEN_PIPE
|
||||
CloseHandle(newstdout); // Close this handle (duplicated in subprocess) now so we get ERROR_BROKEN_PIPE
|
||||
|
||||
char iob[(1024 & ~1) + sizeof(WCHAR)];
|
||||
WCHAR *p = (WCHAR*) iob, wcl = 0;
|
||||
|
@ -774,7 +772,7 @@ DWORD WINAPI MakeNSISProc(LPVOID TreadParam) {
|
|||
cb += cbio, cch = cb / sizeof(WCHAR);
|
||||
if (!cch)
|
||||
{
|
||||
if (!rok) break; // TODO: if cb is non-zero we should report a incomplete read error?
|
||||
if (!rok) break; // TODO: If cb is non-zero we should report a incomplete read error?
|
||||
cbofs += cbio; // We only have 1 byte, need to read more to get a complete WCHAR
|
||||
continue;
|
||||
}
|
||||
|
@ -919,11 +917,8 @@ INT_PTR CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
|
|||
switch(msg) {
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for(i = (int)COMPRESSOR_SCRIPT; i <= (int)COMPRESSOR_BEST; i++) {
|
||||
for(int i = (int)COMPRESSOR_SCRIPT; i <= (int)COMPRESSOR_BEST; i++)
|
||||
SendDlgItemMessage(hwndDlg, IDC_COMPRESSOR, CB_ADDSTRING, 0, (LPARAM)compressor_display_names[i]);
|
||||
}
|
||||
SendDlgItemMessage(hwndDlg, IDC_COMPRESSOR, CB_SETCURSEL, (WPARAM)g_sdata.default_compressor, (LPARAM)0);
|
||||
|
||||
SetSymbols(hwndDlg, g_sdata.symbols);
|
||||
|
|
|
@ -186,7 +186,7 @@ void SetDialogFocus(HWND hDlg, HWND hCtl)
|
|||
SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)hCtl, TRUE);
|
||||
}
|
||||
|
||||
void Items(HWND hwnd, int on)
|
||||
void EnableDisableItems(HWND hwnd, int on)
|
||||
{
|
||||
const HWND hCloseBtn = GetDlgItem(hwnd, IDCANCEL);
|
||||
const HWND hTestBtn = GetDlgItem(hwnd, IDC_TEST);
|
||||
|
@ -234,12 +234,12 @@ void SetCompressorStats()
|
|||
|
||||
line_count = SendDlgItemMessage(g_sdata.hwnd, IDC_LOGWIN, EM_GETLINECOUNT, 0, 0);
|
||||
for(i=0; i<line_count; i++) {
|
||||
*((LPWORD)buf) = sizeof(buf);
|
||||
SendDlgItemMessage(g_sdata.hwnd, IDC_LOGWIN, EM_GETLINE, (WPARAM)i, (LPARAM)buf);
|
||||
*((LPWORD)buf) = ARRAYSIZE(buf);
|
||||
LRESULT cchLine = SendDlgItemMessage(g_sdata.hwnd, IDC_LOGWIN, EM_GETLINE, (WPARAM)i, (LPARAM)buf);
|
||||
buf[cchLine] = _T('\0');
|
||||
if(found) {
|
||||
DWORD len = lstrlen(TOTAL_SIZE_COMPRESSOR_STAT);
|
||||
lstrcat(g_sdata.compressor_stats,buf);
|
||||
|
||||
if(!StrCmpN(buf,TOTAL_SIZE_COMPRESSOR_STAT,len)) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ void ClearLog(HWND hwnd);
|
|||
void LogMessage(HWND hwnd,const TCHAR *str);
|
||||
void ErrorMessage(HWND hwnd,const TCHAR *str);
|
||||
void SetDialogFocus(HWND hDlg, HWND hCtl); // Use this and not SetFocus()!
|
||||
#define DisableItems(hwnd) Items(hwnd, 0)
|
||||
#define EnableItems(hwnd) Items(hwnd, 1)
|
||||
void Items(HWND hwnd, int on);
|
||||
#define DisableItems(hwnd) EnableDisableItems(hwnd, 0)
|
||||
#define EnableItems(hwnd) EnableDisableItems(hwnd, 1)
|
||||
void EnableDisableItems(HWND hwnd, int on);
|
||||
bool OpenRegSettingsKey(HKEY &hKey, bool create = false);
|
||||
DWORD ReadRegSettingDW(LPCTSTR name, const DWORD defval);
|
||||
void RestoreWindowPos(HWND hwnd);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue