From 58e3b830e9a6826fef8950bccd7b173bf56de8b2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 16 May 2024 13:58:56 +0200 Subject: [PATCH] lib/nfs/FileReader: clear the read_buffer in CancelRead() Fixes assertion failure with libnfs 6. --- src/lib/nfs/FileReader.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/nfs/FileReader.cxx b/src/lib/nfs/FileReader.cxx index 71bcc74c6..da045332f 100644 --- a/src/lib/nfs/FileReader.cxx +++ b/src/lib/nfs/FileReader.cxx @@ -138,7 +138,14 @@ void NfsFileReader::CancelRead() noexcept { if (state == State::READ) { - connection->Cancel(*this, nullptr, {}); + DisposablePointer dispose_value{}; + +#ifdef LIBNFS_API_2 + assert(read_buffer); + dispose_value = ToDeleteArray(read_buffer.release()); +#endif + + connection->Cancel(*this, nullptr, std::move(dispose_value)); state = State::IDLE; } }