diff --git a/AK/FileStream.h b/AK/FileStream.h index 0355ec16f950420448c18292cd96d964bc0a3de2..27138b0f347c55e534c90776bb803e25213d7a48 100644 --- a/AK/FileStream.h +++ b/AK/FileStream.h @@ -54,8 +54,9 @@ public: ~InputFileStream() { if (m_file) { + fflush(m_file); if (m_owned) - fflush(m_file); + fclose(m_file); } } diff --git a/Services/ProtocolServer/ClientConnection.cpp b/Services/ProtocolServer/ClientConnection.cpp index eee7277869fe2cb0b00fdf8bce2ab7e7b664c839..45ef0e2683d03483990d7cdecb27428fbaa2dbd2 100644 --- a/Services/ProtocolServer/ClientConnection.cpp +++ b/Services/ProtocolServer/ClientConnection.cpp @@ -72,7 +72,9 @@ OwnPtr ClientConnection::handle auto id = download->id(); auto fd = download->download_fd(); m_downloads.set(id, move(download)); - return make(id, fd); + auto response = make(id, fd); + response->on_destruction = [fd] { close(fd); }; + return response; } OwnPtr ClientConnection::handle(const Messages::ProtocolServer::StopDownload& message)