Commit e58052d8 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

kernelbase: Avoid memory leaks in GetConsoleTitleW().

parent 0c3d7826
...@@ -1057,16 +1057,17 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW( LPWSTR title, DWORD size ) ...@@ -1057,16 +1057,17 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW( LPWSTR title, DWORD size )
if (!(params = HeapAlloc( GetProcessHeap(), 0, max_size ))) if (!(params = HeapAlloc( GetProcessHeap(), 0, max_size )))
return 0; return 0;
if (!console_ioctl( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle, IOCTL_CONDRV_GET_TITLE, if (console_ioctl( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle, IOCTL_CONDRV_GET_TITLE,
NULL, 0, params, max_size, &size )) NULL, 0, params, max_size, &size ) &&
return 0; size >= sizeof(*params))
{
if (size < sizeof(*params)) return 0; size -= sizeof(*params);
memcpy( title, params->buffer, size );
title[ size / sizeof(WCHAR) ] = 0;
size = params->title_len;
}
else size = 0;
size -= sizeof(*params);
memcpy( title, params->buffer, size );
title[ size / sizeof(WCHAR) ] = 0;
size = params->title_len;
HeapFree( GetProcessHeap(), 0, params ); HeapFree( GetProcessHeap(), 0, params );
return size; return size;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment