Make sure RestoreLastError is only called with a valid error code

This commit is contained in:
Whindmar Saksit 2023-10-25 16:10:52 +02:00
parent e962b67f40
commit 866d4d8001

View file

@ -606,7 +606,7 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
STARTUPINFOW startup;
PROCESS_INFORMATION info;
UINT_PTR retval = SE_ERR_NOASSOC;
UINT gcdret = 0, gle;
UINT gcdret = 0, gle = 0;
WCHAR curdir[MAX_PATH];
DWORD dwCreationFlags;
const WCHAR *lpDirectory = NULL;
@ -688,7 +688,8 @@ done:
{
if (!SetCurrentDirectoryW(curdir))
ERR("cannot return to directory %s\n", debugstr_w(curdir));
RestoreLastError(gle);
if (gle)
RestoreLastError(gle);
}
return retval;
}