Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: lights_joy on January 23, 2014, 04:06:10 pm

Title: BUG: Memory leak at DebuggerManager::UnregisterDebugger
Post by: lights_joy on January 23, 2014, 04:06:10 pm
i'm using c::b 13.12, in the function
bool DebuggerManager::UnregisterDebugger(cbDebuggerPlugin *plugin)
{
    RegisteredPlugins::iterator it = m_registered.find(plugin);
    if(it == m_registered.end())
        return false;

    m_registered.erase(it);
......
    return true;
}

here just erase the PluginData from the vector,  but this operation will NOT free the content of PluginData::m_configurations (there's at least one cbDebuggerConfiguration* object),
so I think it's better to call
   it->second.ClearConfigurations();
before erase,  or there will be a memory leak.

I think the author may want to free all objects at the destructor:
DebuggerManager::~DebuggerManager()
{
    for (RegisteredPlugins::iterator it = m_registered.begin(); it != m_registered.end(); ++it)
      it->second.ClearConfigurations();

    delete m_interfaceFactory;
}

in fact, every cbDebuggerPlugin will call UnregisterDebugger first and when the DebuggerManager's destructor is called, there is nothing in the m_registered vector,
so the code in the destructor is useless.



Title: Re: BUG: Memory leak at DebuggerManager::UnregisterDebugger
Post by: oBFusCATed on January 23, 2014, 09:57:07 pm
Fixed in trunk...