Check error code before it is possibly clobbered. Spotted by w3seek. Modified: trunk/reactos/apps/utils/shutdown/shutdown.c _____
Modified: trunk/reactos/apps/utils/shutdown/shutdown.c --- trunk/reactos/apps/utils/shutdown/shutdown.c 2005-01-24 18:47:52 UTC (rev 13250) +++ trunk/reactos/apps/utils/shutdown/shutdown.c 2005-01-24 19:32:40 UTC (rev 13251) @@ -146,7 +146,6 @@
if (! AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0) || ERROR_SUCCESS != GetLastError()) { - CloseHandle(hToken); if (ERROR_NOT_ALL_ASSIGNED == GetLastError()) { _ftprintf(stderr, _T("You are not authorized to shutdown the system\n")); @@ -155,6 +154,7 @@ { _ftprintf(stderr, _T("AdjustTokenPrivileges failed with error %d\n"), (int) GetLastError()); } + CloseHandle(hToken); exit(1); } CloseHandle(hToken);