Validate entity in GameRules_GetPropEnt and in CS_DropWeapon safety checks.

This commit is contained in:
Nicholas Hastings
2012-12-17 14:34:44 -05:00
parent 80f7e3092b
commit e9385e6eb6
2 changed files with 8 additions and 3 deletions
+7 -2
View File
@@ -339,9 +339,14 @@ static cell_t GameRules_GetPropEnt(IPluginContext *pContext, const cell_t *param
void *pGameRules = *g_pGameRules;
CBaseHandle &hndl = *(CBaseHandle *)((intptr_t)pGameRules + offset);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(hndl.GetEntryIndex());
int ref = gamehelpers->IndexToReference(hndl.GetEntryIndex());
return gamehelpers->ReferenceToBCompatRef(ref);
if (!pEntity || ((IServerEntity *)pEntity)->GetRefEHandle() != hndl)
{
return -1;
}
return gamehelpers->EntityToBCompatRef(pEntity);
}
static cell_t GameRules_SetPropEnt(IPluginContext *pContext, const cell_t *params)