From 4e8453b7bf8845e00c77d421125c3695c31ffed4 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 19 Mar 2018 19:15:52 +0100 Subject: [PATCH] nic_router: destroy list items during for_each The for_each method of the List wrapper remembers the next list item before calling the functor on the current one, so, the current one can be destroyed during the functor. Ref #2670 --- repos/os/src/server/nic_router/list.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/repos/os/src/server/nic_router/list.h b/repos/os/src/server/nic_router/list.h index d49bbebd08..1c8d1ae14b 100644 --- a/repos/os/src/server/nic_router/list.h +++ b/repos/os/src/server/nic_router/list.h @@ -29,10 +29,11 @@ struct Net::List : Genode::List template void for_each(FUNC && functor) { - for (LT * elem = Base::first(); elem; - elem = elem->Base::Element::next()) + for (LT *elem = Base::first(); elem; ) { + LT *const next = elem->Base::Element::next(); functor(*elem); + elem = next; } }