From da2c6b62f2284c6f7909053e7ccab848e0ac3356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Wed, 16 Oct 2013 15:30:53 +0200 Subject: [PATCH] core: fix iterating over trace policies Fixes #920. --- base/src/core/include/trace/policy_registry.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/base/src/core/include/trace/policy_registry.h b/base/src/core/include/trace/policy_registry.h index 4a5b9f4f4b..b3d9cb19fe 100644 --- a/base/src/core/include/trace/policy_registry.h +++ b/base/src/core/include/trace/policy_registry.h @@ -80,7 +80,7 @@ class Genode::Trace::Policy_registry Policy *_unsynchronized_lookup(Policy_owner const &owner, Policy_id id) { - for (Policy *p = _policies.first(); p; p++) + for (Policy *p = _policies.first(); p; p = p->next()) if (p->is_owned_by(owner) && p->has_id(id)) return p; @@ -89,7 +89,7 @@ class Genode::Trace::Policy_registry Policy *_any_policy_owned_by(Policy_owner const &owner) { - for (Policy *p = _policies.first(); p; p++) + for (Policy *p = _policies.first(); p; p = p->next()) if (p->is_owned_by(owner)) return p; @@ -119,9 +119,15 @@ class Genode::Trace::Policy_registry { Lock::Guard guard(_lock); - for (Policy *p = _policies.first(); p; p++) - if (p->is_owned_by(owner) && p->has_id(id)) - destroy(&p->md_alloc(), p); + for (Policy *p = _policies.first(); p; ) { + Policy *tmp = p; + p = p->next(); + + if (tmp->is_owned_by(owner) && tmp->has_id(id)) { + _policies.remove(tmp); + destroy(&tmp->md_alloc(), tmp); + } + } } void destroy_policies_owned_by(Policy_owner const &owner)