diff --git a/AK/FileStream.h b/AK/FileStream.h index 0355ec16f95..27138b0f347 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 eee7277869f..45ef0e2683d 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)