Assertion trying to delete an empty object
<p>trying to solve a mem leak I've changed this:</p>

<pre><code>void addListener(IListener* listener, const std::string&amp; appender )
{
     std::pair&lt;t_ListenerVectorMap::iterator,bool&gt; p =
    listenerVectorMap.insert(std::string(appender), new t_ListenerVector);
    p.first-&gt;second-&gt;push_back(listener);

    //add the appender
    addAppender(appender);
}
</code></pre>

<p>By this:</p>

<pre><code>void addListener( IListener* listener,const std::string&amp; appender )
{
    t_ListenerVector* lv = new t_ListenerVector;
    std::pair&lt;t_ListenerVectorMap::iterator,bool&gt; p =
    listenerVectorMap.insert(std::string(appender), lv);

    p.first-&gt;second-&gt;push_back(listener);
    if (!p.second)
    {
        delete lv;
    }

    addAppender(appender);
}
</code></pre>

<p>The leak I'm trying to get ride is the new t_ListenerVector (is a boost::ptr_vector). When appender already exists into listenerVectorMap, then insert operation doesn't not modify contents of map, so new t_ListenerVector isn't inserted and becomes a mem leak.</p>

<p>The change is to avoid this leak. If no new insertion as been done, lv is not inserted so I do remove it. But the problem is that delete lv throws an assertion (in vc\include\vector Line:70).
If lv hasn't been changed, why this error?</p>

<p>Some ideas are welcome.
Thanks</p>
