HANDLE NULL check the converted value, not the string length

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6639 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2015-11-22 12:44:49 +00:00
parent 8f65eb3c23
commit 9d883f98d8

View file

@ -1342,8 +1342,8 @@ static int NSISCALL ExecuteEntry(entry *entry_)
#ifdef NSIS_SUPPORT_FILEFUNCTIONS #ifdef NSIS_SUPPORT_FILEFUNCTIONS
case EW_FCLOSE: case EW_FCLOSE:
{ {
TCHAR *t=var0; HANDLE handle = (HANDLE) strtoiptr(var0);
if (*t) CloseHandle((HANDLE)strtoiptr(t)); if (handle) CloseHandle(handle);
} }
break; break;
case EW_FOPEN: case EW_FOPEN:
@ -1375,7 +1375,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
if (writeCodPt) // FileWriteByte or FileWriteWord if (writeCodPt) // FileWriteByte or FileWriteWord
{ {
// Note: In Unicode version, we put a WORD in buf1[0] and will write 1 or 2 bytes, depending on FileWriteByte/Word. // Note: In Unicode version, we put a WORD in buf1[0] and will write 1 or 2 bytes, depending on FileWriteByte/Word.
((_TUCHAR *)buf1)[0]=(_TUCHAR) GetIntFromParm(1); // FIX_ENDIAN_INT16 needed? ((_TUCHAR *)buf1)[0]=(_TUCHAR) GetIntFromParm(1);
l=(ansi)?1:sizeof(TCHAR); l=(ansi)?1:sizeof(TCHAR);
} }
#ifdef _UNICODE #ifdef _UNICODE
@ -1488,16 +1488,16 @@ static int NSISCALL ExecuteEntry(entry *entry_)
#ifdef NSIS_SUPPORT_FINDFIRST #ifdef NSIS_SUPPORT_FINDFIRST
case EW_FINDCLOSE: case EW_FINDCLOSE:
{ {
TCHAR *t=var0; HANDLE hFind = (HANDLE) strtoiptr(var0);
if (*t) FindClose((HANDLE)strtoiptr(t)); if (hFind) FindClose(hFind);
} }
break; break;
case EW_FINDNEXT: case EW_FINDNEXT:
{ {
TCHAR *textout=var0; TCHAR *textout=var0;
TCHAR *t=var1; HANDLE hFind = (HANDLE) strtoiptr(var1);
WIN32_FIND_DATA fd; WIN32_FIND_DATA fd;
if (*t && FindNextFile((HANDLE)strtoiptr(t),&fd)) if (hFind && FindNextFile(hFind,&fd))
{ {
mystrcpy(textout,fd.cFileName); mystrcpy(textout,fd.cFileName);
} }