commit cde5d60fcfa48df9959eeb6c709f26ba89ebef5f
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Sat Jun 17 09:43:01 2017 +0200

    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 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/BufferList.cpp b/src/BufferList.cpp
index b068f66..8a94c42 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();
        }
 }
 

Reply via email to