1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

Enforce the is_node_list contract in lib-config setters.

An assertion failure is better than a segfault.
This commit is contained in:
LemonBoy 2016-11-29 23:08:45 +01:00
parent 1aff5c2c97
commit 7fb84b5b7d

View File

@ -82,6 +82,7 @@ void config_node_clear(CONFIG_REC *rec, CONFIG_NODE *node)
void config_nodes_remove_all(CONFIG_REC *rec) void config_nodes_remove_all(CONFIG_REC *rec)
{ {
g_return_if_fail(rec != NULL); g_return_if_fail(rec != NULL);
g_return_if_fail(is_node_list(rec->mainnode));
while (rec->mainnode->value != NULL) while (rec->mainnode->value != NULL)
config_node_remove(rec, rec->mainnode, ((GSList *) rec->mainnode->value)->data); config_node_remove(rec, rec->mainnode, ((GSList *) rec->mainnode->value)->data);
@ -94,6 +95,7 @@ void config_node_set_str(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key,
g_return_if_fail(rec != NULL); g_return_if_fail(rec != NULL);
g_return_if_fail(parent != NULL); g_return_if_fail(parent != NULL);
g_return_if_fail(is_node_list(parent));
no_key = key == NULL; no_key = key == NULL;
node = no_key ? NULL : config_node_find(parent, key); node = no_key ? NULL : config_node_find(parent, key);