From 148c9a1b8603b159ac9b7c1614052f9cca1bd110 Mon Sep 17 00:00:00 2001 From: kichik Date: Mon, 8 Sep 2003 10:38:34 +0000 Subject: [PATCH] Fixed VIAddVersionKey failing on empty inputs git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2881 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/ResourceVersionInfo.cpp | 6 +++--- Source/exehead/exec.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) 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) {