From 56e2174cf6dad9c1e664877d27e3ca9c4ae2c512 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 21 May 2018 20:30:24 +1000 Subject: [PATCH] Do not reuse m_buffer_trash to store dying buffers in ~BufferManager Doing that clears m_buffer_trash, deleting buffers contained there, but we are not ready to have Buffer destructors running yet as we did not clear the ClientManager, meaning we might have free windows pointing to buffers in the buffer trash. --- src/buffer_manager.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index 4a6e779f..a26caa40 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -13,11 +13,10 @@ namespace Kakoune BufferManager::~BufferManager() { - // Move buffers to m_buffer_trash to avoid running BufClose - // hook while clearing m_buffers - m_buffer_trash = std::move(m_buffers); + // Move buffers to avoid running BufClose with buffers remaining in that list + BufferList buffers = std::move(m_buffers); - for (auto& buffer : m_buffer_trash) + for (auto& buffer : buffers) buffer->on_unregistered(); // Make sure not clients exists