chart2/source/controller/main/ChartController_Insert.cxx |   17 ++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit b739f6af40a49eab507b0bfd4beef4b1a40fb7c9
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon Nov 24 08:30:31 2025 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sat Nov 29 12:58:10 2025 +0100

    null deref of ChartModel in async dialog callback
    
     #0  ___pthread_mutex_lock (mutex=0x108) at ./nptl/pthread_mutex_lock.c:80
     #1  0x0000740d2e7e5e53 in __gthread_mutex_lock (__mutex=0x108)
         at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/x86_64-redhat-linux/bits/gthr-default.h:749
     #2  std::mutex::lock (this=0x108) at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/std_mutex.h:100
     #3  std::unique_lock<std::mutex>::lock (this=0x7ffd19a7d7f0)
         at /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/unique_lock.h:139
     #4  std::unique_lock<std::mutex>::unique_lock (__m=..., 
this=0x7ffd19a7d7f0)
         at /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/unique_lock.h:69
     #5  apphelper::LifeTimeGuard::LifeTimeGuard (rManager=..., 
this=0x7ffd19a7d7f0)
         at 
/home/collabora/jenkins/workspace/build_core_co-25.04_for_online_snapshot/chart2/source/inc/LifeTime.hxx:175
     #6  chart::ChartModel::lockControllers (this=0x0)
         at 
/home/collabora/jenkins/workspace/build_core_co-25.04_for_online_snapshot/chart2/source/model/main/ChartModel.cxx:473
     #7  0x0000740d2e8a220f in 
chart::ControllerLockGuardUNO::ControllerLockGuardUNO 
(this=this@entry=0x7ffd19a7d868,
         xModel=...)
         at 
/home/collabora/jenkins/workspace/build_core_co-25.04_for_online_snapshot/chart2/source/tools/ControllerLockGuard.cxx:32
     #8  0x0000740d2e67a9b9 in operator() (nResult=<optimized out>, 
__closure=0x528ffe80)
         at 
/home/collabora/jenkins/workspace/build_core_co-25.04_for_online_snapshot/chart2/source/controller/main/ChartController_Insert.cxx:514
     #9  std::__invoke_impl<void, 
chart::ChartController::executeDispatch_InsertTrendline()::<lambda(int)>&, int> 
(__f=...)
         at /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/invoke.h:61
     #10 std::__invoke_r<void, 
chart::ChartController::executeDispatch_InsertTrendline()::<lambda(int)>&, int> 
(__fn=...)
         at /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/invoke.h:111
     #11 std::_Function_handler<void(int), 
chart::ChartController::executeDispatch_InsertTrendline()::<lambda(int)> 
>::_M_invoke(const std::_Any_data &, int &&) (__functor=..., 
__args#0=<optimized out>)
    
    Change-Id: Ic95406f6f4894a4e064a5e539741279d7c7a6bab
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194413
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Andras Timar <[email protected]>
    (cherry picked from commit 5495f4d6889dc0c465f0e41219c11d0f8c26ceef)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194809
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/chart2/source/controller/main/ChartController_Insert.cxx 
b/chart2/source/controller/main/ChartController_Insert.cxx
index 5513671a2965..cf95a24180f5 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -465,8 +465,10 @@ void 
ChartController::executeDispatch_InsertMenu_Trendlines()
 
 void ChartController::executeDispatch_InsertTrendline()
 {
+    rtl::Reference<ChartModel> xChartModel = getChartModel();
+
     rtl::Reference< DataSeries > xRegressionCurveContainer =
-        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel());
+        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
xChartModel);
 
     if( !xRegressionCurveContainer.is() )
         return;
@@ -487,7 +489,7 @@ void ChartController::executeDispatch_InsertTrendline()
     auto aItemConverter = 
std::make_shared<wrapper::RegressionCurveItemConverter>(
         xCurve, xRegressionCurveContainer, 
m_pDrawModelWrapper->getSdrModel().GetItemPool(),
         m_pDrawModelWrapper->getSdrModel(),
-        getChartModel() );
+        xChartModel );
 
     // open dialog
     SfxItemSet aItemSet = aItemConverter->CreateEmptyItemSet();
@@ -496,22 +498,23 @@ void ChartController::executeDispatch_InsertTrendline()
         ObjectIdentifier::createDataCurveCID(
             ObjectIdentifier::getSeriesParticleFromCID( 
m_aSelection.getSelectedCID()),
             RegressionCurveHelper::getRegressionCurveIndex( 
xRegressionCurveContainer, xCurve ), false ));
-    aDialogParameter.init( getChartModel() );
+    aDialogParameter.init( xChartModel );
     ViewElementListProvider aViewElementListProvider( 
m_pDrawModelWrapper.get());
     SolarMutexGuard aGuard;
     auto aDialog = std::make_shared<SchAttribTabDlg>(GetChartFrame(), 
&aItemSet, &aDialogParameter,
-                                                     
&aViewElementListProvider, getChartModel());
+                                                     
&aViewElementListProvider, xChartModel);
 
     // note: when a user pressed "OK" but didn't change any settings in the
     // dialog, the SfxTabDialog returns "Cancel"
-    SfxTabDialogController::runAsync(aDialog, [this, aDialog, aItemConverter = 
std::move(aItemConverter),
-                                               
xUndoGuard=std::move(xUndoGuard)](int nResult) {
+    SfxTabDialogController::runAsync(aDialog, [aDialog, aItemConverter = 
std::move(aItemConverter),
+                                               
xUndoGuard=std::move(xUndoGuard),
+                                               
xChartModel=std::move(xChartModel)](int nResult) {
         if ( nResult == RET_OK || aDialog->DialogWasClosedWithOK() )
         {
             const SfxItemSet* pOutItemSet = aDialog->GetOutputItemSet();
             if( pOutItemSet )
             {
-                ControllerLockGuardUNO aCLGuard( getChartModel() );
+                ControllerLockGuardUNO aCLGuard( xChartModel );
                 aItemConverter->ApplyItemSet( *pOutItemSet );
             }
             xUndoGuard->commit();

Reply via email to