Module: wine Branch: stable Commit: 67d961acfd16421be7eba4bc7a006bf8004f8d10 URL: https://gitlab.winehq.org/wine/wine/-/commit/67d961acfd16421be7eba4bc7a006bf...
Author: Alex Henrie alexhenrie24@gmail.com Date: Wed Feb 2 00:23:12 2022 -0700
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 (cherry picked from commit 78df9cb96ccf7d5f2e7919a003209c0b6f6fe021) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
programs/conhost/conhost.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 78f6e345170..3c8d165cbbe 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -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) );