Fix crash on exit (addresses #607).

MutableVal's destructor now checks if the global scope still exists
before trying to remove an identifier from it.
This commit is contained in:
Jon Siwek 2011-09-12 13:16:48 -05:00
parent 2d85ab9818
commit a267c30fcd
2 changed files with 5 additions and 3 deletions

View file

@ -219,5 +219,5 @@ Scope* current_scope()
Scope* global_scope() Scope* global_scope()
{ {
return scopes[0]; return scopes.length() == 0 ? 0 : scopes[0];
} }

View file

@ -638,14 +638,16 @@ MutableVal::~MutableVal()
{ {
for ( list<ID*>::iterator i = aliases.begin(); i != aliases.end(); ++i ) for ( list<ID*>::iterator i = aliases.begin(); i != aliases.end(); ++i )
{ {
global_scope()->Remove((*i)->Name()); if ( global_scope() )
global_scope()->Remove((*i)->Name());
(*i)->ClearVal(); // just to make sure. (*i)->ClearVal(); // just to make sure.
Unref((*i)); Unref((*i));
} }
if ( id ) if ( id )
{ {
global_scope()->Remove(id->Name()); if ( global_scope() )
global_scope()->Remove(id->Name());
id->ClearVal(); // just to make sure. id->ClearVal(); // just to make sure.
Unref(id); Unref(id);
} }