mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Don't crash when the key isn't found.
This commit is contained in:
parent
862729d7a3
commit
2da49e3ca6
@ -153,7 +153,7 @@ int settings_get_choice(const char *key)
|
|||||||
SETTINGS_REC *rec;
|
SETTINGS_REC *rec;
|
||||||
CONFIG_NODE *node;
|
CONFIG_NODE *node;
|
||||||
char *str;
|
char *str;
|
||||||
int idx;
|
int index;
|
||||||
|
|
||||||
rec = settings_get(key, SETTING_TYPE_CHOICE);
|
rec = settings_get(key, SETTING_TYPE_CHOICE);
|
||||||
if (rec == NULL) return -1;
|
if (rec == NULL) return -1;
|
||||||
@ -164,8 +164,10 @@ int settings_get_choice(const char *key)
|
|||||||
str = node == NULL ? rec->default_value.v_string :
|
str = node == NULL ? rec->default_value.v_string :
|
||||||
config_node_get_str(node, key, rec->default_value.v_string);
|
config_node_get_str(node, key, rec->default_value.v_string);
|
||||||
|
|
||||||
idx = strarray_find(rec->choices, str);
|
if (str == NULL || (index = strarray_find(rec->choices, str)) < 0)
|
||||||
return (idx < 0) ? rec->default_value.v_int : idx;
|
return rec->default_value.v_int;
|
||||||
|
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *settings_get_print(SETTINGS_REC *rec)
|
char *settings_get_print(SETTINGS_REC *rec)
|
||||||
|
Loading…
Reference in New Issue
Block a user