From 1e6d787401b548cf3d5cc57d9a0d0f25f1254bf7 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Wed, 7 Feb 2018 11:07:22 +0100 Subject: ensure cap_supported is existent yet --- src/perl/irc/Irc.xs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/perl/irc') diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs index bb2d27bb..3bf81f9a 100644 --- a/src/perl/irc/Irc.xs +++ b/src/perl/irc/Irc.xs @@ -37,14 +37,16 @@ static void perl_irc_server_fill_hash(HV *hv, IRC_SERVER_REC *server) (void) hv_store(hv, "cap_complete", 12, newSViv(server->cap_complete), 0); (void) hv_store(hv, "sasl_success", 12, newSViv(server->sasl_success), 0); - hv_ = newHV(); - g_hash_table_iter_init(&iter, server->cap_supported); - while (g_hash_table_iter_next(&iter, &key_, &val_)) { - char *key = (char *)key_; - char *val = (char *)val_; - hv_store(hv_, key, strlen(key), new_pv(val), 0); + if (server->cap_supported != NULL) { + hv_ = newHV(); + g_hash_table_iter_init(&iter, server->cap_supported); + while (g_hash_table_iter_next(&iter, &key_, &val_)) { + char *key = (char *)key_; + char *val = (char *)val_; + hv_store(hv_, key, strlen(key), new_pv(val), 0); + } + (void) hv_store(hv, "cap_supported", 13, newRV_noinc((SV*)hv_), 0); } - (void) hv_store(hv, "cap_supported", 13, newRV_noinc((SV*)hv_), 0); av = newAV(); for (tmp = server->cap_active; tmp != NULL; tmp = tmp->next) -- cgit v1.2.3