mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -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;
|
||||
CONFIG_NODE *node;
|
||||
char *str;
|
||||
int idx;
|
||||
int index;
|
||||
|
||||
rec = settings_get(key, SETTING_TYPE_CHOICE);
|
||||
if (rec == NULL) return -1;
|
||||
@ -164,8 +164,10 @@ int settings_get_choice(const char *key)
|
||||
str = node == NULL ? rec->default_value.v_string :
|
||||
config_node_get_str(node, key, rec->default_value.v_string);
|
||||
|
||||
idx = strarray_find(rec->choices, str);
|
||||
return (idx < 0) ? rec->default_value.v_int : idx;
|
||||
if (str == NULL || (index = strarray_find(rec->choices, str)) < 0)
|
||||
return rec->default_value.v_int;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
char *settings_get_print(SETTINGS_REC *rec)
|
||||
|
Loading…
Reference in New Issue
Block a user