diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-08-10 14:34:57 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-08-10 15:50:18 +0200 |
commit | e226c2e147348790438390c9712f3ad0068045b5 (patch) | |
tree | 56f8ba3457c6d3594795e20d034fab323b93a231 /src/plugins/irc/irc-nick.c | |
parent | 890a9e54be5b96d55f05d3221991a17bbd605a68 (diff) | |
download | weechat-e226c2e147348790438390c9712f3ad0068045b5.zip |
irc: free nick immediately in case of malloc error
Diffstat (limited to 'src/plugins/irc/irc-nick.c')
-rw-r--r-- | src/plugins/irc/irc-nick.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index f5c05c1a1..a3f800a45 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -664,6 +664,17 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, new_nick->host = (host) ? strdup (host) : NULL; length = strlen (irc_server_get_prefix_chars (server)); new_nick->prefixes = malloc (length + 1); + if (!new_nick->name || !new_nick->prefixes) + { + if (new_nick->name) + free (new_nick->name); + if (new_nick->host) + free (new_nick->host); + if (new_nick->prefixes) + free (new_nick->prefixes); + free (new_nick); + return NULL; + } if (new_nick->prefixes) { memset (new_nick->prefixes, ' ', length); |