Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/conhost/window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/programs/conhost/window.c b/programs/conhost/window.c index 4033eefa313..5881ad9c3ad 100644 --- a/programs/conhost/window.c +++ b/programs/conhost/window.c @@ -303,7 +303,8 @@ static void save_registry_key( HKEY key, const struct console_config *config ) val = config->edition_mode; RegSetValueExW( key, L"EditionMode", 0, REG_DWORD, (BYTE *)&val, sizeof(val) );
- RegSetValueExW( key, L"FaceName", 0, REG_SZ, (BYTE *)&config->face_name, sizeof(config->face_name) ); + RegSetValueExW( key, L"FaceName", 0, REG_SZ, (BYTE *)&config->face_name, + (lstrlenW(config->face_name) + 1) * sizeof(WCHAR) );
val = config->font_pitch_family; RegSetValueExW( key, L"FontPitchFamily", 0, REG_DWORD, (BYTE *)&val, sizeof(val) );
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/conhost/conhost.c | 11 +++++++---- programs/conhost/window.c | 29 ++++++++++++----------------- 2 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index ecfdd082a81..859f15ced01 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -97,9 +97,12 @@ static struct screen_buffer *create_screen_buffer( struct console *console, int screen_buffer->popup_attr = console->active->attr; screen_buffer->font = console->active->font;
- if (!(screen_buffer->font.face_name = malloc( screen_buffer->font.face_len ))) return NULL; - memcpy( screen_buffer->font.face_name, console->active->font.face_name, - screen_buffer->font.face_len ); + if (screen_buffer->font.face_len) + { + screen_buffer->font.face_name = malloc((screen_buffer->font.face_len + 1) * sizeof(WCHAR)); + if (!screen_buffer->font.face_name) return NULL; + lstrcpyW(screen_buffer->font.face_name, console->active->font.face_name); + } } else { @@ -1728,7 +1731,7 @@ static NTSTATUS get_output_info( struct screen_buffer *screen_buffer, size_t *ou { struct condrv_output_info *info;
- *out_size = min( *out_size, sizeof(*info) + screen_buffer->font.face_len ); + *out_size = min( *out_size, sizeof(*info) + (screen_buffer->font.face_len * sizeof(WCHAR))); if (!(info = alloc_ioctl_buffer( *out_size ))) return STATUS_NO_MEMORY;
info->cursor_size = screen_buffer->cursor_size; diff --git a/programs/conhost/window.c b/programs/conhost/window.c index 5881ad9c3ad..70346a63ca5 100644 --- a/programs/conhost/window.c +++ b/programs/conhost/window.c @@ -242,7 +242,6 @@ static void load_config( const WCHAR *key_name, struct console_config *config ) TRACE("loading %s registry settings.\n", wine_dbgstr_w( key_name ));
memcpy( config->color_map, color_map, sizeof(color_map) ); - memset( config->face_name, 0, sizeof(config->face_name) ); config->cursor_size = 25; config->cursor_visible = 1; config->font_pitch_family = FIXED_PITCH | FF_DONTCARE; @@ -683,9 +682,8 @@ static BOOL set_console_font( struct console *console, const LOGFONTW *logfont ) if (console->window->font && logfont->lfHeight == console->active->font.height && logfont->lfWeight == console->active->font.weight && !logfont->lfItalic && !logfont->lfUnderline && !logfont->lfStrikeOut && - console->active->font.face_len == wcslen( logfont->lfFaceName ) * sizeof(WCHAR) && - !memcmp( logfont->lfFaceName, console->active->font.face_name, - console->active->font.face_len )) + console->active->font.face_len == wcslen(logfont->lfFaceName) && + lstrcmpW(logfont->lfFaceName, console->active->font.face_name)) { TRACE( "equal to current\n" ); return TRUE; @@ -708,9 +706,9 @@ static BOOL set_console_font( struct console *console, const LOGFONTW *logfont ) font_info->weight = tm.tmWeight;
free( font_info->face_name ); - font_info->face_len = wcslen( logfont->lfFaceName ) * sizeof(WCHAR); - font_info->face_name = malloc( font_info->face_len ); - memcpy( font_info->face_name, logfont->lfFaceName, font_info->face_len ); + font_info->face_len = wcslen(logfont->lfFaceName); + font_info->face_name = malloc((font_info->face_len + 1) * sizeof(WCHAR)); + lstrcpyW(font_info->face_name, logfont->lfFaceName);
/* FIXME: use maximum width for DBCS codepages since some chars take two cells */ if (GetCPInfo( console->output_cp, &cpinfo ) && cpinfo.MaxCharSize > 1) @@ -819,9 +817,9 @@ static int WINAPI get_first_font_sub_enum( const LOGFONTW *lf, const TEXTMETRICW load_config( fc->console->window->config_key, &config ); config.cell_width = fc->console->active->font.width; config.cell_height = fc->console->active->font.height; - fc->console->active->font.face_len = wcslen( config.face_name ) * sizeof(WCHAR); - memcpy( fc->console->active->font.face_name, config.face_name, - fc->console->active->font.face_len ); + fc->console->active->font.face_len = wcslen(config.face_name); + lstrcpyW(fc->console->active->font.face_name, config.face_name); + /* Force also its writing back to the registry so that we can get it * the next time. */ @@ -1895,8 +1893,8 @@ static void apply_config( struct console *console, const struct console_config * console->active->font.height != config->cell_height || console->active->font.weight != config->font_weight || console->active->font.pitch_family != config->font_pitch_family || - console->active->font.face_len != wcslen( config->face_name ) * sizeof(WCHAR) || - memcmp( console->active->font.face_name, config->face_name, console->active->font.face_len )) + console->active->font.face_len != wcslen(config->face_name) || + lstrcmpW(console->active->font.face_name, config->face_name)) { update_console_font( console, config->face_name, config->cell_height, config->font_weight ); } @@ -1908,8 +1906,6 @@ static void apply_config( struct console *console, const struct console_config *
static void current_config( struct console *console, struct console_config *config ) { - size_t len; - config->menu_mask = console->window->menu_mask; config->quick_edit = console->window->quick_edit;
@@ -1930,9 +1926,8 @@ static void current_config( struct console *console, struct console_config *conf config->cell_height = console->active->font.height; config->font_weight = console->active->font.weight; config->font_pitch_family = console->active->font.pitch_family; - len = min( ARRAY_SIZE(config->face_name) - 1, console->active->font.face_len / sizeof(WCHAR) ); - if (len) memcpy( config->face_name, console->active->font.face_name, len * sizeof(WCHAR) ); - config->face_name[len] = 0; + lstrcpyW(config->face_name, console->active->font.face_name); + config->face_name[console->active->font.face_len] = 0;
config->sb_width = console->active->width; config->sb_height = console->active->height;
On 8/9/21 1:52 PM, Hugh McMaster wrote:
Signed-off-by: Hugh McMasterhugh.mcmaster@outlook.com
programs/conhost/conhost.c | 11 +++++++---- programs/conhost/window.c | 29 ++++++++++++----------------- 2 files changed, 19 insertions(+), 21 deletions(-)
This crashes in kernel32 console tests for me.
Jacek
On Tue, 10 Aug 2021 at 05:28, Jacek Caban wrote:
On 8/9/21 1:52 PM, Hugh McMaster wrote:
Signed-off-by: Hugh McMaster
programs/conhost/conhost.c | 11 +++++++---- programs/conhost/window.c | 29 ++++++++++++----------------- 2 files changed, 19 insertions(+), 21 deletions(-)
This crashes in kernel32 console tests for me.
Hi Jacek,
I’ll take another look. Do you know roughly which tests were running?