From: Jānis Rūcis Date: Tue, 30 Mar 2010 17:40:50 +0000 (+0300) Subject: IRC: clean up parsing sanity checks X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a337579c5dca2ece4d0ad4991bcd8116c97010f8;p=xonotic%2Fdarkplaces.git IRC: clean up parsing sanity checks --- diff --git a/irc.c b/irc.c index 91c1ee12..91faf7ee 100644 --- a/irc.c +++ b/irc.c @@ -163,14 +163,6 @@ static ircmessage_t *IRC_ParseMessage(const char *line) len = strcspn(line, " "); - /* TODO, is this really needed? */ - - if (line + len == line_end) - { - IRC_FreeMessage(msg); - return NULL; - } - msg->prefix = Z_Malloc(len + 1); memcpy(msg->prefix, line, len); msg->prefix[len] = 0; @@ -181,17 +173,23 @@ static ircmessage_t *IRC_ParseMessage(const char *line) else msg->prefix = NULL; + if (line == line_end) + { + IRC_FreeMessage(msg); + return NULL; + } + len = strcspn(line, " "); msg->command = Z_Malloc(len + 1); memcpy(msg->command, line, len); msg->command[len] = 0; - if (line + len != line_end) - { - line += len; - line += strspn(line, " "); + line += len; + line += strspn(line, " "); + if (line != line_end) + { len = line_end - line; msg->args = Z_Malloc(len + 1);