News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

CB crashes in wxSmith code

Started by killerbot, June 25, 2006, 05:55:20 PM

Previous topic - Next topic

killerbot

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 :


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).

byo

Bad bug, bad bug :oops: Fetching project pointer should be done before removing from ProjectMap.