ensure a buffer is not referenced a second time, just before actually deleting it

It can happen in certain case that a buffer gets referenced after it
gets moved to the trash, for example when it gets deleted during its
construction (due to BufCreate hook for example).
This commit is contained in:
Maxime Coste 2015-08-06 21:51:44 +01:00
parent c41870ec98
commit 7a59a6d758

View File

@ -114,7 +114,16 @@ void BufferManager::backup_modified_buffers()
void BufferManager::clear_buffer_trash() void BufferManager::clear_buffer_trash()
{ {
while (not m_buffer_trash.empty()) while (not m_buffer_trash.empty())
delete m_buffer_trash.back().get(); {
Buffer* buffer = m_buffer_trash.back().get();
// Do that again, to be tolerant in some corner cases, where a buffer is
// deleted during its creation
if (ClientManager::has_instance())
ClientManager::instance().ensure_no_client_uses_buffer(*buffer);
delete buffer;
}
} }
} }