Update parent buffer as soon as a child has been released

This prevents dangling pointers that might crash LyX.

Fixes: #9979.
This commit is contained in:
Juergen Spitzmueller 2017-06-17 09:43:01 +02:00
parent e5105a0dce
commit f61e88b7dd
2 changed files with 8 additions and 0 deletions

View File

@ -98,10 +98,15 @@ void BufferList::release(Buffer * buf)
BufferStorage::iterator const it = BufferStorage::iterator const it =
find(bstore.begin(), bstore.end(), buf); find(bstore.begin(), bstore.end(), buf);
if (it != bstore.end()) { if (it != bstore.end()) {
Buffer const * parent = buf ? buf->parent() : 0;
Buffer * tmp = (*it); Buffer * tmp = (*it);
bstore.erase(it); bstore.erase(it);
LASSERT(tmp, return); LASSERT(tmp, return);
delete tmp; 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();
} }
} }

View File

@ -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 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). - Remove duplicate entries from the Symbols dialog (bug 10644).
- Always show the float type in the float inset label (bug 10618). - Always show the float type in the float inset label (bug 10618).