diff --git a/src/MusicBuffer.cxx b/src/MusicBuffer.cxx index 2555656df..92fc9a884 100644 --- a/src/MusicBuffer.cxx +++ b/src/MusicBuffer.cxx @@ -39,6 +39,12 @@ MusicBuffer::Return(MusicChunk *chunk) noexcept { assert(chunk != nullptr); + /* these attributes need to be cleared before locking the + mutex, because they might recursively call this method, + causing a deadlock */ + chunk->next.reset(); + chunk->other.reset(); + const std::lock_guard protect(mutex); assert(!chunk->other || !chunk->other->other);