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
This commit is contained in:
Martin Stein 2018-03-19 19:15:52 +01:00 committed by Christian Helmuth
parent 930c29a50c
commit 4e8453b7bf

View File

@ -29,10 +29,11 @@ struct Net::List : Genode::List<LT>
template <typename FUNC>
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;
}
}