1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-30 03:26:23 -04: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:
Jonas Fonseca 2006-06-07 17:33:21 +02:00 committed by Kalle Olavi Niemitalo
parent 3b5258db0e
commit 51572671c9

View File

@ -49,22 +49,29 @@ void
charset_list(struct terminal *term, void *xxx, void *ses_)
{
struct session *ses = ses_;
int i;
int i, items;
int sel = int_max(0, get_opt_codepage_tree(term->spec, "charset"));
struct menu_item *mi = new_menu(FREE_LIST);
if (!mi) return;
for (i = 0; ; i++) {
for (i = 0, items = 0; ; i++) {
unsigned char *name = get_cp_name(i);
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,
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);
}