--- cppu/source/uno/EnvStack.cxx.orig	2007-06-25 23:02:11.000000000 +0200
+++ cppu/source/uno/EnvStack.cxx	2007-06-25 23:04:23.000000000 +0200
@@ -92,7 +92,8 @@
 	else
 	{
 		ThreadMap::iterator iEnv = s_threadMap.find(threadId);
-		s_threadMap.erase(iEnv);
+		if(iEnv != s_threadMap.end())
+		   s_threadMap.erase(iEnv);
 	}
 }
 
