event/Loop: AbandonFD() unlinks the SocketEvent

Fixes use-after-free bugs causing assertion failures at shutdown,
because all "abandoned" SocketEvents are still in the linked list.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/986
Closes https://github.com/MusicPlayerDaemon/MPD/issues/987
This commit is contained in:
Max Kellermann 2020-10-28 14:59:55 +01:00
parent 65a1c4a016
commit 7c47fe746c
1 changed files with 2 additions and 0 deletions

View File

@ -110,6 +110,8 @@ EventLoop::AbandonFD(SocketEvent &event) noexcept
#endif
assert(event.IsDefined());
event.unlink();
return poll_backend.Abandon(event.GetSocket().Get());
}