diff --git a/core/CConVarManager.cpp b/core/CConVarManager.cpp index 32cfd609..734379a0 100644 --- a/core/CConVarManager.cpp +++ b/core/CConVarManager.cpp @@ -97,7 +97,7 @@ void CConVarManager::OnPluginDestroyed(IPlugin *plugin) void CConVarManager::OnHandleDestroy(HandleType_t type, void *object) { ConVarInfo *info; - ConCommandBase *cvar = static_cast(object); + ConVar *cvar = static_cast(object); // Find convar in lookup trie sm_trie_retrieve(m_ConVarCache, cvar->GetName(), reinterpret_cast(&info)); @@ -105,6 +105,11 @@ void CConVarManager::OnHandleDestroy(HandleType_t type, void *object) // If convar was created by SourceMod plugin... if (info->sourceMod) { + // Delete string allocations + delete [] cvar->GetName(); + delete [] cvar->GetDefault(); + delete [] cvar->GetHelpText(); + // Then unregister it g_SMAPI->UnregisterConCmdBase(g_PLAPI, cvar); } @@ -205,7 +210,7 @@ Handle_t CConVarManager::CreateConVar(IPluginContext *pContext, const char *name } // Since we didn't find an existing convar (or concmd with the same name), now we can finally create it! - cvar = new ConVar(name, defaultVal, flags, helpText, hasMin, min, hasMax, max); + cvar = new ConVar(sm_strdup(name), sm_strdup(defaultVal), flags, sm_strdup(helpText), hasMin, min, hasMax, max); // Find plugin creating convar IPlugin *pl = g_PluginSys.FindPluginByContext(pContext->GetContext()); diff --git a/core/smn_bitbuffer.cpp b/core/smn_bitbuffer.cpp index cc3adf9f..b6692069 100644 --- a/core/smn_bitbuffer.cpp +++ b/core/smn_bitbuffer.cpp @@ -12,10 +12,10 @@ * Version: $Id$ */ -#include -#include #include "sourcemod.h" #include "HandleSys.h" +#include +#include static cell_t smn_BfWriteBool(IPluginContext *pCtx, const cell_t *params) {