]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fix segfault sendcvar for non existing cvars introduced in r6933
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 14 Apr 2007 20:44:36 +0000 (20:44 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 14 Apr 2007 20:44:36 +0000 (20:44 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7095 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c

index d60489b35b390b0ee4c709b7f9e3a7b0a22291a3..bac0d1424776a3556a672d62739b1eb3cb7ce006 100644 (file)
@@ -1955,17 +1955,19 @@ void Host_SendCvar_f (void)
 {
        int             i;
        cvar_t  *c;
+       const char *cvarname;
        client_t *old;
 
        if(Cmd_Argc() != 2)
                return;
-       c = Cvar_FindVar(Cmd_Argv(1));
+       cvarname = Cmd_Argv(1);
        if (cls.state == ca_connected)
        {
+               c = Cvar_FindVar(cvarname);
                // LordHavoc: if there is no such cvar or if it is private, send a
                // reply indicating that it has no value
                if(!c || (c->flags & CVAR_PRIVATE))
-                       Cmd_ForwardStringToServer(va("sentcvar %s\n", c->name));
+                       Cmd_ForwardStringToServer(va("sentcvar %s\n", cvarname));
                else
                        Cmd_ForwardStringToServer(va("sentcvar %s \"%s\"\n", c->name, c->string));
                return;
@@ -1982,7 +1984,7 @@ void Host_SendCvar_f (void)
                if(svs.clients[i].active && svs.clients[i].netconnection)
                {
                        host_client = &svs.clients[i];
-                       Host_ClientCommands(va("sendcvar %s\n", c->name));
+                       Host_ClientCommands(va("sendcvar %s\n", cvarname));
                }
        host_client = old;
 }