From f843f904bc9fc1c8d0d2dfddd5e15aaa9738ec0d Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 28 Aug 2011 15:25:30 +0200 Subject: core: fix bugs with calls to realloc --- src/plugins/relay/relay-client-irc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/plugins/relay') diff --git a/src/plugins/relay/relay-client-irc.c b/src/plugins/relay/relay-client-irc.c index 2c7eda9b1..a48e298be 100644 --- a/src/plugins/relay/relay-client-irc.c +++ b/src/plugins/relay/relay-client-irc.c @@ -469,7 +469,7 @@ void relay_client_irc_send_join (struct t_relay_client *client, const char *channel) { - char *infolist_name, *nicks; + char *infolist_name, *nicks, *nicks2; const char *nick, *prefix, *topic; char *host; int length, length_nicks; @@ -540,7 +540,14 @@ relay_client_irc_send_join (struct t_relay_client *client, length_nicks += strlen (nick) + 1 + 1; if (nicks) { - nicks = realloc (nicks, length_nicks); + nicks2 = realloc (nicks, length_nicks); + if (!nicks2) + { + if (nicks) + free (nicks); + return; + } + nicks = nicks2; strcat (nicks, " "); } else -- cgit v1.2.3