diff --git a/src/os_win32.c b/src/os_win32.c index 81a31409d..eedd0a5ab 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -918,9 +918,8 @@ null_libintl_wputenv(const wchar_t *envstring UNUSED) * Enables or disables the specified privilege. */ static BOOL -win32_enable_privilege(LPTSTR lpszPrivilege, BOOL bEnable) +win32_enable_privilege(LPTSTR lpszPrivilege) { - BOOL bResult; LUID luid; HANDLE hToken; TOKEN_PRIVILEGES tokenPrivileges; @@ -937,15 +936,22 @@ win32_enable_privilege(LPTSTR lpszPrivilege, BOOL bEnable) tokenPrivileges.PrivilegeCount = 1; tokenPrivileges.Privileges[0].Luid = luid; - tokenPrivileges.Privileges[0].Attributes = bEnable ? - SE_PRIVILEGE_ENABLED : 0; + tokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - bResult = AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, - sizeof(TOKEN_PRIVILEGES), NULL, NULL); + if (!AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, 0, NULL, NULL)) + { + CloseHandle(hToken); + return FALSE; + } + + if (GetLastError() != ERROR_SUCCESS) + { + CloseHandle(hToken); + return FALSE; + } CloseHandle(hToken); - - return bResult && GetLastError() == ERROR_SUCCESS; + return TRUE; } #endif @@ -961,15 +967,11 @@ win32_enable_privilege(LPTSTR lpszPrivilege, BOOL bEnable) void PlatformId(void) { - static int done = FALSE; - - if (done) - return; - OSVERSIONINFO ovi; ovi.dwOSVersionInfoSize = sizeof(ovi); - GetVersionEx(&ovi); + if (!GetVersionEx(&ovi)) + return; #ifdef FEAT_EVAL vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d", @@ -985,9 +987,9 @@ PlatformId(void) #ifdef HAVE_ACL // Enable privilege for getting or setting SACLs. - win32_enable_privilege(SE_SECURITY_NAME, TRUE); + if (!win32_enable_privilege(SE_SECURITY_NAME)) + return; #endif - done = TRUE; } #ifdef _MSC_VER # pragma warning(pop) diff --git a/src/version.c b/src/version.c index becaa3e4b..76d1889ee 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 780, /**/ 779, /**/