From b0075842d13c46b6d88dcad84900c517fc553d3b Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Sun, 26 Aug 2012 23:33:11 -0400 Subject: [PATCH] Fixed minor memory leaks in cstrike ext (bug 5456, r=psychonic). --- extensions/cstrike/natives.cpp | 8 ++++---- extensions/cstrike/util_cstrike.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/cstrike/natives.cpp b/extensions/cstrike/natives.cpp index f463c55b..965278bf 100644 --- a/extensions/cstrike/natives.cpp +++ b/extensions/cstrike/natives.cpp @@ -210,17 +210,17 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params) } //Psychonic is awesome for this - sm_sendprop_info_t *spi = new sm_sendprop_info_t; + sm_sendprop_info_t spi; IServerUnknown *pUnk = (IServerUnknown *)pWeapon; 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]); - 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]); - CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pWeapon + spi->actual_offset); + CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pWeapon + spi.actual_offset); if (params[1] != hndl.GetEntryIndex()) return pContext->ThrowNativeError("Weapon %d is not owned by client %d", params[2], params[1]); diff --git a/extensions/cstrike/util_cstrike.cpp b/extensions/cstrike/util_cstrike.cpp index 328a5a78..d0d1ac86 100644 --- a/extensions/cstrike/util_cstrike.cpp +++ b/extensions/cstrike/util_cstrike.cpp @@ -90,7 +90,7 @@ const char *GetTranslatedWeaponAlias(const char *weapon) retpass.size = sizeof(const char *); \ pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1)) } - const char *ret = new char[128]; + const char *ret = NULL; unsigned char vstk[sizeof(const char *)]; unsigned char *vptr = vstk;