1
0
mirror of https://github.com/irssi/irssi.git synced 2024-06-30 06:45:25 +00:00

Prevent a NULL pointer deference

Always create the cap_supported table when a CAP event is received.
This commit is contained in:
LemonBoy 2017-10-23 12:42:37 +02:00
parent 432368bdc6
commit f683e81880

View File

@ -135,19 +135,21 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add
return;
}
/* The table is created only when needed */
if (server->cap_supported == NULL) {
server->cap_supported = g_hash_table_new_full(g_str_hash,
g_str_equal,
g_free, g_free);
}
/* Strip the trailing whitespaces before splitting the string, some servers send responses with
* superfluous whitespaces that g_strsplit the interprets as tokens */
caps = g_strsplit(g_strchomp(list), " ", -1);
caps_length = g_strv_length(caps);
if (!strcmp(evt, "LS")) {
if (server->cap_supported) {
g_hash_table_destroy(server->cap_supported);
}
/* Start with a fresh table */
server->cap_supported = g_hash_table_new_full(g_str_hash,
g_str_equal,
g_free, g_free);
/* Throw away everything and start from scratch */
g_hash_table_remove_all(server->cap_supported);
/* Create a list of the supported caps */
for (i = 0; i < caps_length; i++) {