From a267c30fcdc48a602a57caaa3cf723009aad34aa Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Mon, 12 Sep 2011 13:16:48 -0500 Subject: [PATCH] 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. --- src/Scope.cc | 2 +- src/Val.cc | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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); }