Merge branch 'fix-forceskin-none-segfault' into 'next'

Fix segfault when setting forceskin to None

See merge request STJr/SRB2!2478
This commit is contained in:
Lactozilla 2024-06-09 05:04:42 +00:00
commit 332445ae55

View file

@ -2065,11 +2065,10 @@ static void CV_SetValueMaybeStealth(consvar_t *var, INT32 value, boolean stealth
if (var == &cv_forceskin) // Special handling. if (var == &cv_forceskin) // Special handling.
{ {
const char *tmpskin = NULL; const char *tmpskin = NULL;
if ((value < 0) || (value >= numskins)) if (value >= 0 && value < numskins)
;
else
tmpskin = skins[value]->name; tmpskin = skins[value]->name;
memcpy(val, tmpskin, SKINNAMESIZE); if (tmpskin)
memcpy(val, tmpskin, SKINNAMESIZE);
} }
else else
sprintf(val, "%d", value); sprintf(val, "%d", value);