diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-11-23 23:51:16 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-11-23 23:51:16 +0000 |
| commit | 8f2c6eb58659bac11014ca0e58de0e5c85a90ff0 (patch) | |
| tree | 0a78927c377675f2125f82eb1c896c2d9f79d470 /src | |
| parent | b884b499dd58d47c6c9da5d7ee244dd8cb591288 (diff) | |
Fix write_all_buffers when BufWrite... hooks create/delete buffers
The buffer list can be mutated during iteration, so it is no safe
to directly iterate on the BufferManager, we need to first create
our own copy of the buffer list.
Fixes #935
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/commands.cc b/src/commands.cc index c16d5dd9..f711a525 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -340,7 +340,12 @@ const CommandDesc write_cmd = { void write_all_buffers() { + // Copy buffer list because hooks might be creating/deleting buffers + Vector<SafePtr<Buffer>> buffers; for (auto& buffer : BufferManager::instance()) + buffers.emplace_back(buffer.get()); + + for (auto& buffer : buffers) { if ((buffer->flags() & Buffer::Flags::File) and buffer->is_modified() and !(buffer->flags() & Buffer::Flags::ReadOnly)) |
