conhost: Fix memory leak on error path in create_screen_buffer (cppcheck).

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alex Henrie 2022-02-02 00:23:12 -07:00 committed by Alexandre Julliard
parent 36af682895
commit 78df9cb96c
1 changed files with 5 additions and 1 deletions

View File

@ -100,7 +100,11 @@ static struct screen_buffer *create_screen_buffer( struct console *console, int
if (screen_buffer->font.face_len)
{
screen_buffer->font.face_name = malloc( screen_buffer->font.face_len * sizeof(WCHAR) );
if (!screen_buffer->font.face_name) return NULL;
if (!screen_buffer->font.face_name)
{
free( screen_buffer );
return NULL;
}
memcpy( screen_buffer->font.face_name, console->active->font.face_name,
screen_buffer->font.face_len * sizeof(WCHAR) );