mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 08:54:05 +00:00
kernelbase: Avoid memory leaks in GetConsoleTitleW().
This commit is contained in:
parent
0c3d78269f
commit
e58052d836
|
@ -1057,16 +1057,17 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW( LPWSTR title, DWORD size )
|
|||
if (!(params = HeapAlloc( GetProcessHeap(), 0, max_size )))
|
||||
return 0;
|
||||
|
||||
if (!console_ioctl( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle, IOCTL_CONDRV_GET_TITLE,
|
||||
NULL, 0, params, max_size, &size ))
|
||||
return 0;
|
||||
if (console_ioctl( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle, IOCTL_CONDRV_GET_TITLE,
|
||||
NULL, 0, params, max_size, &size ) &&
|
||||
size >= sizeof(*params))
|
||||
{
|
||||
size -= sizeof(*params);
|
||||
memcpy( title, params->buffer, size );
|
||||
title[ size / sizeof(WCHAR) ] = 0;
|
||||
size = params->title_len;
|
||||
}
|
||||
else size = 0;
|
||||
|
||||
if (size < sizeof(*params)) return 0;
|
||||
|
||||
size -= sizeof(*params);
|
||||
memcpy( title, params->buffer, size );
|
||||
title[ size / sizeof(WCHAR) ] = 0;
|
||||
size = params->title_len;
|
||||
HeapFree( GetProcessHeap(), 0, params );
|
||||
return size;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue