summaryrefslogtreecommitdiff
path: root/cppu/source/uno/EnvStack.cxx
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2013-05-02 09:24:10 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-09 09:30:45 +0100
commit1ad6f436b5cd937dfc9d91c284920efddd6ad185 (patch)
tree6f85b4d4f1f615e71eb12ac181ba10ea75f08990 /cppu/source/uno/EnvStack.cxx
parent1cab60bb06d7e45ffb33298dbda1d752431a3a55 (diff)
protect UNO EnvStack's s_setCurrent() against unknown threadid
untracked threadIds have been observed and can result in crashes. s_getCurrent() already checks them and s_setCurrent() does it now. (cherry picked from commit bf8e3135ac906ce0ab7d6d9ccbd434f1597f2ff4) Conflicts: cppu/source/uno/EnvStack.cxx Change-Id: If35237179c1ee3b854e6183294ed72a6d0b105a8
Diffstat (limited to 'cppu/source/uno/EnvStack.cxx')
-rw-r--r--cppu/source/uno/EnvStack.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/cppu/source/uno/EnvStack.cxx b/cppu/source/uno/EnvStack.cxx
index cafd4fe23b75..22d7bd992909 100644
--- a/cppu/source/uno/EnvStack.cxx
+++ b/cppu/source/uno/EnvStack.cxx
@@ -74,10 +74,15 @@ static void s_setCurrent(uno_Environment * pEnv)
osl::MutexGuard guard(s_threadMap_mutex::get());
ThreadMap &rThreadMap = s_threadMap::get();
if (pEnv)
+ {
rThreadMap[threadId] = pEnv;
-
+ }
else
- rThreadMap.erase(threadId);
+ {
+ ThreadMap::iterator iEnv = rThreadMap.find(threadId);
+ if( iEnv != rThreadMap.end())
+ rThreadMap.erase(iEnv);
+ }
}
static uno_Environment * s_getCurrent(void)