we shouldn't parse args if there are no args
authorpk910 <philipp@zoelle1.de>
Sat, 13 Aug 2011 00:45:46 +0000 (02:45 +0200)
committerpk910 <philipp@zoelle1.de>
Sat, 13 Aug 2011 00:45:46 +0000 (02:45 +0200)
modcmd.c

index 1f6a5415cc8c366c97d9f131aabf421a3d1cb29e..6db797b257733afaa03b4061cd45054f7c7b06f4 100644 (file)
--- a/modcmd.c
+++ b/modcmd.c
@@ -85,15 +85,17 @@ static void handle_command(struct ClientSocket *client, struct UserNode *user, s
             char *arga[MAXNUMPARAMS];
             char **argv;
             int argc = 0;
-            while(*args) {
-                //skip leading spaces
-                while (*args == ' ')
-                    *args++ = 0;
-                arga[argc++] = args;
-                if (argc >= MAXNUMPARAMS)
-                    break;
-                while (*args != ' ' && *args)
-                    args++;
+            if(args) {
+                while(*args) {
+                    //skip leading spaces
+                    while (*args == ' ')
+                        *args++ = 0;
+                    arga[argc++] = args;
+                    if (argc >= MAXNUMPARAMS)
+                        break;
+                    while (*args != ' ' && *args)
+                        args++;
+                }
             }
             argv = arga;
             if(argc != 0 && argv[0][0] == '#') {