From cde5d60fcfa48df9959eeb6c709f26ba89ebef5f Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 17 Jun 2017 09:43:01 +0200 Subject: [PATCH] Update parent buffer as soon as a child has been released This prevents dangling pointers that might crash LyX. Fixes: #9979. Candidate for stable. --- src/BufferList.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/BufferList.cpp b/src/BufferList.cpp index b068f66e5e..8a94c4208c 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -96,10 +96,15 @@ void BufferList::release(Buffer * buf) BufferStorage::iterator const it = find(bstore.begin(), bstore.end(), buf); if (it != bstore.end()) { + Buffer const * parent = buf ? buf->parent() : 0; Buffer * tmp = (*it); bstore.erase(it); LASSERT(tmp, return); delete tmp; + if (parent) + // If this was a child, update the parent's buffer + // to avoid crashes due to dangling pointers (bug 9979) + parent->updateBuffer(); } } -- 2.39.5