event/BufferedSocket: OnSocketReady() returns true after close

Fixes use-after-free bug (https://bugs.musicpd.org/view.php?id=4548).
This commit is contained in:
Max Kellermann
2016-07-07 13:52:20 +02:00
parent 6f59d71e07
commit b46cf57d98
2 changed files with 8 additions and 1 deletions

View File

@@ -118,9 +118,15 @@ BufferedSocket::OnSocketReady(unsigned flags)
if (flags & READ) {
assert(!input.IsFull());
if (!ReadToBuffer() || !ResumeInput())
if (!ReadToBuffer())
return false;
if (!ResumeInput())
/* we must return "true" here or
SocketMonitor::Dispatch() will call
Cancel() on a freed object */
return true;
if (!input.IsFull())
ScheduleRead();
}