Skip to content

Commit 6347b60

Browse files
authored
PRVM_GarbageCollection: Add range check on string garbage collection (#294)
When using FTEQCC structs, it's possible for string variables to be outside the string global space. This can cause the garbage collector to segfault. This PR checks that the index is within bounds and will display a debug message and skip any that are not.
1 parent c6b823c commit 6347b60

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

prvm_edict.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,6 +3817,12 @@ void PRVM_GarbageCollection(prvm_prog_t *prog)
38173817
if (s & PRVM_KNOWNSTRINGBASE)
38183818
{
38193819
prvm_int_t num = s - PRVM_KNOWNSTRINGBASE;
3820+
3821+
if (num < 0 || num >= prog->numknownstrings)
3822+
{
3823+
continue;
3824+
}
3825+
38203826
if (!prog->knownstrings[num])
38213827
{
38223828
// invalid

0 commit comments

Comments
 (0)