[PATCH] conhost: Fix memory leak on error path in create_screen_buffer (cppcheck)
Alex Henrie
alexhenrie24 at gmail.com
Mon Dec 20 23:01:36 CST 2021
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
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) );
--
2.34.1
More information about the wine-devel
mailing list