Module: wine Branch: master Commit: 6891faf454f74a9b377e66a6e34a4bfd96e84707 URL: https://gitlab.winehq.org/wine/wine/-/commit/6891faf454f74a9b377e66a6e34a4bf...
Author: Hugh McMaster hugh.mcmaster@outlook.com Date: Sat Mar 18 22:54:42 2023 +1100
conhost: Save original console title on initialization.
---
programs/conhost/conhost.c | 29 +++++++++++++++++++++++------ programs/conhost/conhost.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 1bed7b8a03c..f07164c698e 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -2461,21 +2461,38 @@ static NTSTATUS scroll_output( struct screen_buffer *screen_buffer, const struct return STATUS_SUCCESS; }
+static WCHAR *set_title( const WCHAR *in_title, size_t size ) +{ + WCHAR *title = NULL; + + title = malloc( size + sizeof(WCHAR) ); + if (!title) return NULL; + + memcpy( title, in_title, size ); + title[ size / sizeof(WCHAR) ] = 0; + + return title; +} + static NTSTATUS set_console_title( struct console *console, const WCHAR *in_title, size_t size ) { WCHAR *title = NULL;
TRACE( "%s\n", debugstr_wn(in_title, size / sizeof(WCHAR)) );
- if (size) - { - if (!(title = malloc( size + sizeof(WCHAR) ))) return STATUS_NO_MEMORY; - memcpy( title, in_title, size ); - title[size / sizeof(WCHAR)] = 0; - } + if (!(title = set_title( in_title, size ))) + return STATUS_NO_MEMORY; + free( console->title ); console->title = title;
+ if (!console->title_orig && !(console->title_orig = set_title( in_title, size ))) + { + free( console->title ); + console->title = NULL; + return STATUS_NO_MEMORY; + } + if (console->tty_output) { size_t len; diff --git a/programs/conhost/conhost.h b/programs/conhost/conhost.h index 4464f51032f..76d897e8800 100644 --- a/programs/conhost/conhost.h +++ b/programs/conhost/conhost.h @@ -93,6 +93,7 @@ struct console unsigned int key_state; struct console_window *window; WCHAR *title; /* console title */ + WCHAR *title_orig; /* original console title */ struct history_line **history; /* lines history */ unsigned int history_size; /* number of entries in history array */ unsigned int history_index; /* number of used entries in history array */