Skip to content

Commit 89c2428

Browse files
committed
networking: fix two impossible yet existing memory issues
1 parent ec2bdb2 commit 89c2428

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

source/modules/networking.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,8 @@ struct EntityTransmitCache // Well.... Still kinda acts as a tick-based cache, t
11051105
memmove(&pFullEntityList[i], &pFullEntityList[i + 1], (nFullEdictCount - i) * sizeof(CBaseEntity*));
11061106

11071107
--nFullEdictCount;
1108-
pFullEntityList[nFullEdictCount] = NULL;
1108+
if (nFullEdictCount >= 0)
1109+
pFullEntityList[nFullEdictCount] = NULL;
11091110
break;
11101111
}
11111112

@@ -1119,7 +1120,8 @@ struct EntityTransmitCache // Well.... Still kinda acts as a tick-based cache, t
11191120
memmove(&pPVSEntityList[i], &pPVSEntityList[i + 1], (nPVSEdictCount - i) * sizeof(CBaseEntity*));
11201121

11211122
--nPVSEdictCount;
1122-
pPVSEntityList[nPVSEdictCount] = NULL;
1123+
if (nPVSEdictCount >= 0)
1124+
pPVSEntityList[nPVSEdictCount] = NULL;
11231125
break;
11241126
}
11251127

@@ -1134,7 +1136,7 @@ struct EntityTransmitCache // Well.... Still kinda acts as a tick-based cache, t
11341136
if (pArea.pEntities[i] != pEntity)
11351137
continue;
11361138

1137-
if (i < pArea.nCount - 1)
1139+
if (i < (pArea.nCount - 1))
11381140
memmove(&pArea.pEntities[i], &pArea.pEntities[i + 1], (pArea.nCount - i - 1) * sizeof(CBaseEntity*));
11391141

11401142
--pArea.nCount;

0 commit comments

Comments
 (0)