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