From 2bd35de5cf811af8f8019549fcdb5ccf2af7af93 Mon Sep 17 00:00:00 2001 From: Henry Castro Date: Mon, 7 Sep 2015 17:43:04 -0400 Subject: [PATCH 1/6] vcl: assign nullptr after deleting In the preinit stage, the VCL initialization is done by the parent process and when the lo_startmain thread de-initialize the VCL, some services are disposed early, and it causes segmentation violation. So it is ensured that pointers to service objetcs is set nullptr after deleting. Change-Id: I65ecfc2d2694a981ec2986988efabdfd28d0cce4 (cherry picked from commit 4886676a5b50caf0946b91491055cbdc2696f1ca) --- vcl/source/app/svdata.cxx | 4 ++-- vcl/source/app/svmain.cxx | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index 71d7628..0bbba59 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -102,10 +102,10 @@ void ImplDeInitSVData() // delete global instance data if( pSVData->mpSettingsConfigItem ) - delete pSVData->mpSettingsConfigItem; + delete pSVData->mpSettingsConfigItem, pSVData->mpSettingsConfigItem = nullptr; if( pSVData->mpDockingManager ) - delete pSVData->mpDockingManager; + delete pSVData->mpDockingManager, pSVData->mpDockingManager = nullptr; if( pSVData->maCtrlData.mpFieldUnitStrings ) delete pSVData->maCtrlData.mpFieldUnitStrings, pSVData->maCtrlData.mpFieldUnitStrings = NULL; diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx index 23757e8..3202019 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -380,7 +380,7 @@ void DeInitVCL() delete pSVData->mpSettingsConfigItem, pSVData->mpSettingsConfigItem = NULL; if ( pSVData->maAppData.mpIdleMgr ) - delete pSVData->maAppData.mpIdleMgr; + delete pSVData->maAppData.mpIdleMgr, pSVData->maAppData.mpIdleMgr = nullptr; Scheduler::ImplDeInitScheduler(); if ( pSVData->maWinData.mpMsgBoxImgList ) @@ -539,7 +539,11 @@ void DeInitVCL() pSVData->mpSalTimer = NULL; // Deinit Sal - DestroySalInstance( pSVData->mpDefInst ); + if (pSVData->mpDefInst) + { + DestroySalInstance( pSVData->mpDefInst ); + pSVData->mpDefInst = nullptr; + } if( pOwnSvApp ) { @@ -566,7 +570,7 @@ struct WorkerThreadData static HANDLE hThreadID = 0; static unsigned __stdcall _threadmain( void *pArgs ) { - OleInitialize( NULL ); + OleInitialize( nullptr ); ((WorkerThreadData*)pArgs)->pWorker( ((WorkerThreadData*)pArgs)->pThreadData ); delete (WorkerThreadData*)pArgs; OleUninitialize(); -- 2.9.3