# HG changeset patch # User Scott Ehlert # Date 1171690411 0 # Node ID c29f8796bcf46872ab75b0027a38c947dfe8140d # Parent 546acad59370b6a189558deb1add5b3bae8ed99f Initial fixes to ensure static strings passed to new convars Also fixed minor warning in smn_bitbuffer.cpp diff -r 546acad59370 -r c29f8796bcf4 core/CConVarManager.cpp --- a/core/CConVarManager.cpp Sat Feb 17 04:37:47 2007 +0000 +++ b/core/CConVarManager.cpp Sat Feb 17 05:33:31 2007 +0000 @@ -97,7 +97,7 @@ 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 @@ // 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 @@ } // 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 -r 546acad59370 -r c29f8796bcf4 core/smn_bitbuffer.cpp --- a/core/smn_bitbuffer.cpp Sat Feb 17 04:37:47 2007 +0000 +++ b/core/smn_bitbuffer.cpp Sat Feb 17 05:33:31 2007 +0000 @@ -12,10 +12,10 @@ * Version: $Id$ */ +#include "sourcemod.h" +#include "HandleSys.h" #include #include -#include "sourcemod.h" -#include "HandleSys.h" static cell_t smn_BfWriteBool(IPluginContext *pCtx, const cell_t *params) {