mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 19:26:29 +00:00
guard SetConsoleInputExeNameW() with SEH to properly release the console lock in case of failure
svn path=/trunk/; revision=12179
This commit is contained in:
parent
0ad5627d13
commit
b79bb15644
1 changed files with 19 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: console.c,v 1.86 2004/12/18 13:26:57 weiden Exp $
|
||||
/* $Id: console.c,v 1.87 2004/12/18 13:33:09 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -3422,6 +3422,7 @@ BOOL STDCALL SetConsoleIcon(HICON hicon)
|
|||
BOOL STDCALL
|
||||
SetConsoleInputExeNameW(LPCWSTR lpInputExeName)
|
||||
{
|
||||
BOOL Ret = FALSE;
|
||||
int lenName = lstrlenW(lpInputExeName);
|
||||
|
||||
if(lenName < 1 ||
|
||||
|
@ -3433,11 +3434,25 @@ SetConsoleInputExeNameW(LPCWSTR lpInputExeName)
|
|||
}
|
||||
|
||||
RtlEnterCriticalSection(&ConsoleLock);
|
||||
/* wrap copying into SEH as we may copy from invalid buffer and in case of an
|
||||
exception the console lock would've never been released, which would cause
|
||||
further calls (if the exception was handled by the caller) to recursively
|
||||
acquire the lock... */
|
||||
_SEH_TRY
|
||||
{
|
||||
RtlCopyMemory(InputExeName, lpInputExeName, lenName * sizeof(WCHAR));
|
||||
InputExeName[lenName] = L'\0';
|
||||
Ret = TRUE;
|
||||
}
|
||||
_SEH_HANDLE
|
||||
{
|
||||
lenName = 0;
|
||||
SetLastErrorByStatus(_SEH_GetExceptionCode());
|
||||
}
|
||||
_SEH_END;
|
||||
RtlLeaveCriticalSection(&ConsoleLock);
|
||||
|
||||
return TRUE;
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue