Fixed minor memory leaks in cstrike ext (bug 5456, r=psychonic).

This commit is contained in:
Kyle Sanderson 2012-08-27 00:57:25 -04:00
parent f2eccadff3
commit 129395c896

View File

@ -206,17 +206,17 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params)
} }
//Psychonic is awesome for this //Psychonic is awesome for this
sm_sendprop_info_t *spi = new sm_sendprop_info_t; sm_sendprop_info_t spi;
IServerUnknown *pUnk = (IServerUnknown *)pWeapon; IServerUnknown *pUnk = (IServerUnknown *)pWeapon;
IServerNetworkable *pNet = pUnk->GetNetworkable(); IServerNetworkable *pNet = pUnk->GetNetworkable();
if (!UTIL_FindDataTable(pNet->GetServerClass()->m_pTable, "DT_WeaponCSBase", spi, 0)) if (!UTIL_FindDataTable(pNet->GetServerClass()->m_pTable, "DT_WeaponCSBase", &spi, 0))
return pContext->ThrowNativeError("Entity index %d is not a weapon", params[2]); return pContext->ThrowNativeError("Entity index %d is not a weapon", params[2]);
if (!gamehelpers->FindSendPropInfo("CBaseCombatWeapon", "m_hOwnerEntity", spi)) if (!gamehelpers->FindSendPropInfo("CBaseCombatWeapon", "m_hOwnerEntity", &spi))
return pContext->ThrowNativeError("Invalid entity index %d for weapon", params[2]); return pContext->ThrowNativeError("Invalid entity index %d for weapon", params[2]);
CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pWeapon + spi->actual_offset); CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pWeapon + spi.actual_offset);
if (params[1] != hndl.GetEntryIndex()) if (params[1] != hndl.GetEntryIndex())
return pContext->ThrowNativeError("Weapon %d is not owned by client %d", params[2], params[1]); return pContext->ThrowNativeError("Weapon %d is not owned by client %d", params[2], params[1]);
@ -312,7 +312,7 @@ static cell_t CS_GetTranslatedWeaponAlias(IPluginContext *pContext, const cell_t
pContext->LocalToString(params[2], &dest); pContext->LocalToString(params[2], &dest);
pContext->LocalToString(params[1], &weapon); pContext->LocalToString(params[1], &weapon);
char *ret = new char[128]; char *ret = NULL;
unsigned char vstk[sizeof(char *)]; unsigned char vstk[sizeof(char *)];
unsigned char *vptr = vstk; unsigned char *vptr = vstk;