mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Fix assertion failure in the charset menu related to special codepages
If the codepage option was set to utf-8 (a special codepage) it would
end up being out of range when used for the initialy selected menu item.
[ From commit a72a0dab08
in ELinks 0.12.GIT.
ELinks 0.11 doesn't support UTF-8 as the terminal codepage, but the
System codepage could cause a similar assertion failure. ELinks 0.11.2
did not yet have this bug. --KON ]
This commit is contained in:
parent
3b5258db0e
commit
51572671c9
@ -49,22 +49,29 @@ void
|
|||||||
charset_list(struct terminal *term, void *xxx, void *ses_)
|
charset_list(struct terminal *term, void *xxx, void *ses_)
|
||||||
{
|
{
|
||||||
struct session *ses = ses_;
|
struct session *ses = ses_;
|
||||||
int i;
|
int i, items;
|
||||||
int sel = int_max(0, get_opt_codepage_tree(term->spec, "charset"));
|
int sel = int_max(0, get_opt_codepage_tree(term->spec, "charset"));
|
||||||
struct menu_item *mi = new_menu(FREE_LIST);
|
struct menu_item *mi = new_menu(FREE_LIST);
|
||||||
|
|
||||||
if (!mi) return;
|
if (!mi) return;
|
||||||
|
|
||||||
for (i = 0; ; i++) {
|
for (i = 0, items = 0; ; i++) {
|
||||||
unsigned char *name = get_cp_name(i);
|
unsigned char *name = get_cp_name(i);
|
||||||
|
|
||||||
if (!name) break;
|
if (!name) break;
|
||||||
if (is_cp_special(i)) continue;
|
if (is_cp_special(i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
items++;
|
||||||
add_to_menu(&mi, name, NULL, ACT_MAIN_NONE,
|
add_to_menu(&mi, name, NULL, ACT_MAIN_NONE,
|
||||||
display_codepage, get_cp_mime_name(i), 0);
|
display_codepage, get_cp_mime_name(i), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Special codepages are not in the menu and it may cause assertion
|
||||||
|
* failures later if the selected item is out of bound. */
|
||||||
|
if (sel >= items)
|
||||||
|
sel = 0;
|
||||||
|
|
||||||
do_menu_selected(term, mi, ses, sel, 0);
|
do_menu_selected(term, mi, ses, sel, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user