]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
IRC: clean up parsing sanity checks
authorJānis Rūcis <parasti@gmail.com>
Tue, 30 Mar 2010 17:40:50 +0000 (20:40 +0300)
committerJānis Rūcis <parasti@gmail.com>
Sun, 27 Jun 2010 12:23:20 +0000 (15:23 +0300)
irc.c

diff --git a/irc.c b/irc.c
index 91c1ee12fd6196c6ae0f4bf07d952bdba4a4c822..91faf7ee194e4e98c563418034e8cf1b7f98ee06 100644 (file)
--- 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);