commit f61e88b7dd85b76e7443a1834766a4e1a4e764d0
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.
---
 src/BufferList.cpp |    5 +++++
 status.22x         |    3 +++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/BufferList.cpp b/src/BufferList.cpp
index fd3f19d..cec9d2d 100644
--- a/src/BufferList.cpp
+++ b/src/BufferList.cpp
@@ -98,10 +98,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();
        }
 }
 
diff --git a/status.22x b/status.22x
index 6a06b68..eb891c8 100644
--- a/status.22x
+++ b/status.22x
@@ -71,6 +71,9 @@ What's new
 
 - Fix crash when closing master file with full view source open (bug 10560).
 
+- Fix crash when closing master document with dirty child while Document
+  Settings dialog is open (bug 9979).
+
 - Remove duplicate entries from the Symbols dialog (bug 10644).
 
 - Always show the float type in the float inset label (bug 10618).

Reply via email to