mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-21 20:11:12 +00:00
Set "allocated" flag to off if setting a string from PossibleValue afterwards, or if not setting a new value at all.
This commit is contained in:
parent
d71b99a56b
commit
70939a7a3d
1 changed files with 4 additions and 0 deletions
|
@ -1433,6 +1433,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
|
|||
if (var->revert.allocated)
|
||||
{
|
||||
Z_Free(var->revert.v.string);
|
||||
var->revert.allocated = false; // the below value is not allocated in zone memory, don't try to free it!
|
||||
}
|
||||
|
||||
var->revert.v.const_munge = var->PossibleValue[i].strvalue;
|
||||
|
@ -1505,6 +1506,7 @@ found:
|
|||
if (var->revert.allocated)
|
||||
{
|
||||
Z_Free(var->revert.v.string);
|
||||
var->revert.allocated = false; // the below value is not allocated in zone memory, don't try to free it!
|
||||
}
|
||||
|
||||
var->revert.v.const_munge = var->PossibleValue[i].strvalue;
|
||||
|
@ -1523,6 +1525,7 @@ found:
|
|||
if (var->revert.allocated)
|
||||
{
|
||||
Z_Free(var->revert.v.string);
|
||||
// Z_StrDup creates a new zone memory block, so we can keep the allocated flag on
|
||||
}
|
||||
|
||||
var->revert.v.string = Z_StrDup(valstr);
|
||||
|
@ -1787,6 +1790,7 @@ void CV_RevertNetVars(void)
|
|||
if (cvar->revert.allocated)
|
||||
{
|
||||
Z_Free(cvar->revert.v.string);
|
||||
cvar->revert.allocated = false; // no value being held now
|
||||
}
|
||||
|
||||
cvar->revert.v.string = NULL;
|
||||
|
|
Loading…
Reference in a new issue