diff --git a/Source/ResourceVersionInfo.cpp b/Source/ResourceVersionInfo.cpp index f55860ba..d7b86308 100644 --- a/Source/ResourceVersionInfo.cpp +++ b/Source/ResourceVersionInfo.cpp @@ -73,9 +73,9 @@ void CResourceVersionInfo::SetProductVersion(int HighPart, int LowPart) // Util function - must be freeded WCHAR* StrToWstrAlloc(const char* istr, int codepage) { - int strSize = strlen(istr); - WCHAR* wstr = new WCHAR[(strSize*2)+1]; - MultiByteToWideChar(codepage, 0, istr, -1, wstr, strSize*2); + int strSize = MultiByteToWideChar(codepage, 0, istr, -1, 0, 0); + WCHAR* wstr = new WCHAR[strSize]; + MultiByteToWideChar(codepage, 0, istr, -1, wstr, strSize); return wstr; } diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 9f774cc3..e50389c7 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -380,13 +380,13 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (overwriteflag >= 3) // check date and time { WIN32_FIND_DATA *ffd=file_exists(buf0); + // if it doesn't exist, overwrite flag will be off (though it doesn't really matter) + int cmp=0; if (ffd) { - // if first one is newer, then don't overwrite - int cmp=CompareFileTime(&ffd->ftLastWriteTime, (FILETIME*)(entry_->offsets + 3)); - overwriteflag=!(cmp & (0x80000000 | (overwriteflag - 3))); + cmp=CompareFileTime(&ffd->ftLastWriteTime, (FILETIME*)(entry_->offsets + 3)); } - // if it doesn't exist, overwrite flag won't matter. it stays on off though. + overwriteflag=!(cmp & (0x80000000 | (overwriteflag - 3))); } if (!overwriteflag) {