Update parent buffer as soon as a child has been released

This prevents dangling pointers that might crash LyX.

Fixes: #9979.

Candidate for stable.
This commit is contained in:
Juergen Spitzmueller 2017-06-17 09:43:01 +02:00
parent 7a9bb85184
commit cde5d60fcf

View File

@ -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();
}
}