diff --git a/src/bfu/dialog.c b/src/bfu/dialog.c index 89e3ed3f1..a7051b1f6 100644 --- a/src/bfu/dialog.c +++ b/src/bfu/dialog.c @@ -310,18 +310,24 @@ select_button_by_key(struct dialog_data *dlg_data) if (widget_data->widget->type != WIDGET_BUTTON) continue; + hk_ptr = widget_data->widget->text; + if (!*hk_ptr) + continue; + /* We first try to match marked hotkey if there is * one else we fallback to first character in button * name. */ hk_pos = widget_data->widget->info.button.hotkey_pos; if (hk_pos >= 0) - hk_ptr = &widget_data->widget->text[hk_pos + 1]; - else - hk_ptr = widget_data->widget->text; + hk_ptr += hk_pos + 1; #ifdef CONFIG_UTF8 hk_char = cp_to_unicode(codepage, &hk_ptr, strchr(hk_ptr, '\0')); + /* hk_char can be UCS_NO_CHAR only if the text of the + * widget is not in the expected codepage. */ + assert(hk_char != UCS_NO_CHAR); + if_assert_failed continue; hk_char = unicode_fold_label_case(hk_char); #else hk_char = toupper(*hk_ptr); diff --git a/src/bfu/hotkey.c b/src/bfu/hotkey.c index 9bfc7681d..9ab50df6a 100644 --- a/src/bfu/hotkey.c +++ b/src/bfu/hotkey.c @@ -179,6 +179,10 @@ check_hotkeys_common(struct menu *menu, term_event_char_T hotkey, struct termina #ifdef CONFIG_UTF8 items_hotkey = cp_to_unicode(codepage, &text, strchr(text, '\0')); + /* items_hotkey can be UCS_NO_CHAR only if the text of + * the menu item is not in the expected codepage. */ + assert(items_hotkey != UCS_NO_CHAR); + if_assert_failed continue; found = (unicode_fold_label_case(items_hotkey) == key); #else found = (toupper(*text) == key);