Author Topic: CB crashes in wxSmith code  (Read 4051 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
CB crashes in wxSmith code
« 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).

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: CB crashes in wxSmith code
« Reply #1 on: June 26, 2006, 10:19:49 am »
Bad bug, bad bug :oops: Fetching project pointer should be done before removing from ProjectMap.