diff --git a/base-foc/src/base/env/cap_map.cc b/base-foc/src/base/env/cap_map.cc index c63d21c99..db31ab107 100644 --- a/base-foc/src/base/env/cap_map.cc +++ b/base-foc/src/base/env/cap_map.cc @@ -89,8 +89,12 @@ void Genode::Capability_map::remove(Genode::Cap_index* i) Lock_guard guard(_lock); if (i) { - _tree.remove(i); - cap_idx_alloc()->free(i,1); + if (_tree.first()) + i = _tree.first()->find_by_id(i->id()); + if (i) { + _tree.remove(i); + cap_idx_alloc()->free(i,1); + } } } diff --git a/base-foc/src/core/cap_session_component.cc b/base-foc/src/core/cap_session_component.cc index 4703bc768..8c188775a 100644 --- a/base-foc/src/core/cap_session_component.cc +++ b/base-foc/src/core/cap_session_component.cc @@ -92,7 +92,7 @@ Cap_mapping::Cap_mapping(Core_cap_index* i, Native_thread_id r) Cap_mapping::~Cap_mapping() { unmap(); - cap_map()->remove(cap_map()->find(local->id())); + cap_map()->remove(local); }