diff --git a/src/Scope.cc b/src/Scope.cc index 196937d984..297446a9f0 100644 --- a/src/Scope.cc +++ b/src/Scope.cc @@ -219,5 +219,5 @@ Scope* current_scope() Scope* global_scope() { - return scopes[0]; + return scopes.length() == 0 ? 0 : scopes[0]; } diff --git a/src/Val.cc b/src/Val.cc index a7dba04550..0285cba645 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -638,14 +638,16 @@ MutableVal::~MutableVal() { for ( list::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. Unref((*i)); } if ( id ) { - global_scope()->Remove(id->Name()); + if ( global_scope() ) + global_scope()->Remove(id->Name()); id->ClearVal(); // just to make sure. Unref(id); }