AmendHub

Download:

jcs

/

wallops

/

amendments

/

75

irc: Bail if allocating a channel fails, we can't recover much


jcs made amendment 75 2 months ago
--- irc.c Mon Sep 9 16:13:58 2024 +++ irc.c Mon Sep 9 16:32:40 2024 @@ -1086,7 +1086,7 @@ not_in_channel: struct irc_channel * irc_create_channel(struct irc_connection *conn, char *channame) { - struct irc_channel *channel = NULL, *tchannel; + struct irc_channel *channel, *tchannel; short n; SLIST_FOREACH(channel, &conn->channels_list, list) { @@ -1097,6 +1097,8 @@ irc_create_channel(struct irc_connection *conn, char * } channel = xmalloczero(sizeof(struct irc_channel)); + if (channel == NULL) + panic("Failed allocating memory for new channel"); SLIST_APPEND(&conn->channels_list, channel, irc_channel, list); channel->connection = conn; strlcpy(channel->name, channame, sizeof(channel->name));