mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 22:15:37 +02:00
Fix potential memory leak in console.c
CAUTION: untested as my openssl installation has gone insane. If the incoming "hScreen" parameter is NULL, a new PSCREEN_RECORD is allocated to use in its place. However, if the allocation of the "pScreenBuf" member variable fails, the function returns, potentially leaking the newly allocated PSCREEN_RECORD. This fix first checks to see if the functions owns the "pScreenRec", and if so, frees it before returning.
This commit is contained in:
parent
89452c8a2f
commit
5d455454de
@ -1608,7 +1608,13 @@ SCREEN_HANDLE ConSaveScreenHandle( SCREEN_HANDLE hScreen )
|
||||
}
|
||||
|
||||
if ( !pScreenRec->pScreenBuf )
|
||||
{
|
||||
// if we allocated a screen within this scope, free it before returning
|
||||
if ( pScreenRec != (PSCREEN_RECORD)hScreen ) {
|
||||
free(pScreenRec);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = ReadConsoleOutput( hConsole, // handle of a console screen buffer
|
||||
(PCHAR_INFO)(pScreenRec->pScreenBuf), // address of buffer that receives data
|
||||
|
Loading…
x
Reference in New Issue
Block a user