From 1fb00b37217a03125aeecebaab029616d1b1493d Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 9 Jan 2023 05:12:46 +0000 Subject: [PATCH] Avoid the use of RETURN_CSTRING for cvar string values that might get cached by qc beyond the engine freeing the implied memory (crashes were reported by pjt/newby). git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6319 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/pr_bgcmd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engine/common/pr_bgcmd.c b/engine/common/pr_bgcmd.c index 48e4b773d..91ee83671 100644 --- a/engine/common/pr_bgcmd.c +++ b/engine/common/pr_bgcmd.c @@ -35,7 +35,7 @@ cvar_t pr_tempstringsize = CVARD("pr_tempstringsize", "4096", "Obsolete"); #ifdef MULTITHREAD cvar_t pr_gc_threaded = CVARD("pr_gc_threaded", "1", "Says whether to use a separate thread for tempstring garbage collections. This avoids main-thread stalls but at the expense of more memory usage."); #else -cvar_t pr_gc_threaded = CVARD("pr_gc_threaded", "0", "Says whether to use a separate thread for tempstring garbage collections. This avoids main-thread stalls but at the expense of more memory usage."); +cvar_t pr_gc_threaded = CVARFD("pr_gc_threaded", "0", CVAR_NOSET|CVAR_NOSAVE, "Says whether to use a separate thread for tempstring garbage collections. This avoids main-thread stalls but at the expense of more memory usage."); #endif cvar_t pr_sourcedir = CVARD("pr_sourcedir", "src", "Subdirectory where your qc source is located. Used by the internal compiler and qc debugging functionality."); cvar_t pr_enable_uriget = CVARD("pr_enable_uriget", "1", "Allows gamecode to make direct http requests"); @@ -1864,9 +1864,9 @@ void QCBUILTIN PF_cvar_string (pubprogfuncs_t *prinst, struct globalvars_s *pr_g if (cv && !(cv->flags & CVAR_NOUNSAFEEXPAND)) { if(cv->latched_string) - RETURN_CSTRING(cv->latched_string); + RETURN_TSTRING(cv->latched_string); else - RETURN_CSTRING(cv->string); + RETURN_TSTRING(cv->string); } else G_INT(OFS_RETURN) = 0; @@ -1883,7 +1883,7 @@ void QCBUILTIN PF_cvar_defstring (pubprogfuncs_t *prinst, struct globalvars_s *p const char *str = PR_GetStringOfs(prinst, OFS_PARM0); cvar_t *cv = PF_Cvar_FindOrGet(str); if (cv && !(cv->flags & CVAR_NOUNSAFEEXPAND)) - RETURN_CSTRING(cv->defaultstr); + RETURN_TSTRING(cv->defaultstr); else G_INT(OFS_RETURN) = 0; } @@ -1896,7 +1896,7 @@ void QCBUILTIN PF_cvar_description (pubprogfuncs_t *prinst, struct globalvars_s if (cv && !(cv->flags & CVAR_NOUNSAFEEXPAND)) { if (cv->description) - RETURN_CSTRING(localtext(cv->description)); + RETURN_TSTRING(localtext(cv->description)); else G_INT(OFS_RETURN) = 0; }