chart2/source/tools/ControllerLockGuard.cxx |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 5f4e12f5e4a9f34dfaabb38dee46a1ba31eb5714
Author:     Andras Timar <[email protected]>
AuthorDate: Tue Feb 24 23:14:01 2026 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Wed Feb 25 09:36:31 2026 +0100

    chart2: fix crash in ControllerLockGuardUNO with null ChartModel
    
    Many callers pass the result of Chart2ModelContact::getDocumentModel()
    which resolves a WeakReference<ChartModel> and can return null if the
    model has been destroyed. Add null checks matching the existing pattern
    in ControllerLockHelper::lockControllers/unlockControllers.
    
    The crash was caused by a race condition where the ChartModel weak
    reference (held in Chart2ModelContact) had expired by the time the
    chart wrapper code tried to lock controllers during a Copy operation.
    The fix gracefully handles the null case instead of dereferencing
    a null pointer.
    
    Change-Id: I43294de12b84cefb062ada12e8a570ad3b7ea571
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200268
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/chart2/source/tools/ControllerLockGuard.cxx 
b/chart2/source/tools/ControllerLockGuard.cxx
index 6bfe8e4a95d2..ac87207a8da1 100644
--- a/chart2/source/tools/ControllerLockGuard.cxx
+++ b/chart2/source/tools/ControllerLockGuard.cxx
@@ -29,12 +29,14 @@ namespace chart
 ControllerLockGuardUNO::ControllerLockGuardUNO( 
rtl::Reference<::chart::ChartModel> xModel ) :
         mxModel(std::move( xModel ))
 {
-    mxModel->lockControllers();
+    if( mxModel.is())
+        mxModel->lockControllers();
 }
 
 ControllerLockGuardUNO::~ControllerLockGuardUNO()
 {
-    mxModel->unlockControllers();
+    if( mxModel.is())
+        mxModel->unlockControllers();
 }
 
 ControllerLockGuard::ControllerLockGuard( ChartModel& rModel ) :

Reply via email to