From 4f50cbcfe405a840459be8682fd4c7521b235798 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 28 Sep 2017 09:06:33 +0200 Subject: [PATCH] Fix crash when closing master with children and grandchildren In some cases, it is possible that the BufferPositionMap has dangling pointers. We thus check whether the Buffer is loaded before accessing it. Fixes: #10766 --- src/Buffer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 11e46ba021..c4ce8ea053 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -3720,8 +3720,12 @@ void Buffer::listMacroNames(MacroNameSet & macros) const // loop over children Impl::BufferPositionMap::iterator it = d->children_positions.begin(); Impl::BufferPositionMap::iterator end = d->children_positions.end(); - for (; it != end; ++it) - it->first->listMacroNames(macros); + for (; it != end; ++it) { + Buffer * child = const_cast(it->first); + // The buffer might have been closed (see #10766). + if (theBufferList().isLoaded(child)) + child->listMacroNames(macros); + } // call parent Buffer const * const pbuf = d->parent(); -- 2.39.2