Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: killerbot on June 25, 2006, 05:55:20 pm

Title: CB crashes in wxSmith code
Post by: killerbot on June 25, 2006, 05:55:20 pm
On my 32 bit system (winXP) (using latest svn), when debugging CB from within CB, and having the debugee opening a project, and then closing that project, I'll get a crash on a delete statement :

Code
void wxSmith::OnProjectClose(CodeBlocksEvent& event)
{
    cbProject* Proj = event.GetProject();
    ProjectMapI i = ProjectMap.find(Proj);
    if ( i != ProjectMap.end() )
    {
        ProjectMap.erase(i);
    }

    wxsProject* SmithProj = (*i).second;

    if ( SmithProj )
    {
//        SmithProj->SaveProject();
        delete SmithProj;
    }

    event.Skip();
}

The SmithProj pointer is 0xfeeefeee, which seems rather bad ;-)
After issuing "ProjectMap.erase(i);" is it still save to "(*i).second" , this might be the problem.

Note : the if test just in front the delete is not needed, in C++ it is save to delete 0-pointers (ok, for those still using that damn non standard word : NULL-pointers).
Title: Re: CB crashes in wxSmith code
Post by: byo on June 26, 2006, 10:19:49 am
Bad bug, bad bug :oops: Fetching project pointer should be done before removing from ProjectMap.