From 85914cc7cd9143b08353409b1dea2a0d536e31de Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 25 Apr 2021 21:55:04 -0700 Subject: [PATCH 1/2] Free zstring when switching to preset value This is only applicable for bounded cvars (MIN, MAX), since otherwise there's no way to allocate a zstring. --- src/command.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/command.c b/src/command.c index f1bf7dfb5..00116a0cb 100644 --- a/src/command.c +++ b/src/command.c @@ -1441,6 +1441,10 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) return; } + // free the old value string + Z_Free(var->zstring); + var->zstring = NULL; + var->value = var->PossibleValue[i].value; var->string = var->PossibleValue[i].strvalue; goto finish; From 92aeadc36b8e32e1c18b25eaac03e0eb9b86171b Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 25 Apr 2021 22:01:40 -0700 Subject: [PATCH 2/2] It is impossible for a string to be allocated in this case --- src/command.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/command.c b/src/command.c index 00116a0cb..951e3dd09 100644 --- a/src/command.c +++ b/src/command.c @@ -1507,14 +1507,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) found: if (client && execversion_enabled) { - 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; - return; }