mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 18:56:29 +00:00
qemu-usb: avoid operating on stale memory
during for loop in garbage_collect Issue #2362
This commit is contained in:
parent
760c04c53a
commit
ecc98c293e
@ -538,12 +538,15 @@ struct Usb_devices : List<Usb_host_device>
|
||||
|
||||
void _garbage_collect()
|
||||
{
|
||||
for (Usb_host_device *d = first(); d; d = d->next()) {
|
||||
if (d->deleted == false)
|
||||
for (Usb_host_device *next = first(); next;) {
|
||||
Usb_host_device *current = next;
|
||||
next = current->next();
|
||||
|
||||
if (current->deleted == false)
|
||||
continue;
|
||||
|
||||
remove(d);
|
||||
Genode::destroy(_alloc, d);
|
||||
remove(current);
|
||||
Genode::destroy(_alloc, current);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user