commit 27132aa63cd1a93b442e4daa1635a44935ab5635
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Wed Feb 12 09:45:36 2025 +0100

    Fix crash when attempting to load a corrupted master from a child (#13151)
    
    Never release a child of a buffer while this child is being loaded.
    Otherwise we will most likely crash upon a dangling pointer.
---
 src/Buffer.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index e2e13b38af..e86f4af227 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -555,7 +555,10 @@ Buffer::~Buffer()
                        if (theBufferList().isLoaded(child)) {
                                if (theBufferList().isOthersChild(this, child))
                                        child->setParent(nullptr);
-                               else
+                               else if (child->isFullyLoaded())
+                                       // only release children if we are not 
currently
+                                       // loading them; otherwise we might get 
dangling
+                                       // pointers (#13151)
                                        theBufferList().release(child);
                        }
                }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to