Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

CB crashes in wxSmith code

(1/1)

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 :


--- 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();
}

--- End code ---

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.

Navigation

[0] Message Index

Go to full version