]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
cvar: Use Mem_strdup to copy off cvar defaults when registering
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 Oct 2020 22:46:00 +0000 (22:46 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 Oct 2020 22:46:00 +0000 (22:46 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13013 d7cf8633-e32d-0410-b094-e92efae38249

cvar.c

diff --git a/cvar.c b/cvar.c
index 22e8f51258f87a08b356f785e8db80cbadf4fc8a..6bac3263c8ba2e14086f85623a76a4e7661f525e 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -546,8 +546,6 @@ void Cvar_RegisterVariable (cvar_t *variable)
 {
        cvar_state_t *cvars = NULL;
        cvar_t *current, *cvar;
-       char *oldstr;
-       size_t alloclen;
        int i;
 
        switch (variable->flags & (CF_CLIENT | CF_SERVER))
@@ -622,12 +620,9 @@ void Cvar_RegisterVariable (cvar_t *variable)
        }
 
        // copy the value off, because future sets will Z_Free it
-       oldstr = (char *)variable->string;
-       alloclen = strlen(variable->string) + 1;
-       variable->string = (char *)Z_Malloc (alloclen);
-       memcpy ((char *)variable->string, oldstr, alloclen);
-       variable->defstring = (char *)Z_Malloc (alloclen);
-       memcpy ((char *)variable->defstring, oldstr, alloclen);
+       variable->name = (char *)Mem_strdup(zonemempool, variable->name);
+       variable->string = (char *)Mem_strdup(zonemempool, variable->string);
+       variable->defstring = (char *)Mem_strdup(zonemempool, variable->string);
        variable->value = atof (variable->string);
        variable->integer = (int) variable->value;
        variable->aliasindex = 0;