Engine: Add error path for remove_entity() and unsafe entity ids

This commit is contained in:
Valentin Grünbacher 2015-05-11 00:15:06 +02:00
parent ff0ca9ba67
commit 679714c8be
2 changed files with 9 additions and 1 deletions

View File

@ -120,6 +120,12 @@ static cell AMX_NATIVE_CALL create_entity(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL remove_entity(AMX *amx, cell *params) static cell AMX_NATIVE_CALL remove_entity(AMX *amx, cell *params)
{ {
int id = params[1]; int id = params[1];
if (id >= 0 && id <= gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d can not be removed", id);
return 0;
}
edict_t *pEnt = INDEXENT2(id); edict_t *pEnt = INDEXENT2(id);
if (FNullEnt(pEnt)) if (FNullEnt(pEnt))

View File

@ -621,6 +621,8 @@ native create_entity(const szClassname[]);
* *
* @return 1 if entity was sucessfully removed, 0 if an invalid entity * @return 1 if entity was sucessfully removed, 0 if an invalid entity
* was provided * was provided
* @error If an entity index in the range of 0 to MaxClients is
* provided, an error will be thrown.
*/ */
native remove_entity(iIndex); native remove_entity(iIndex);