kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-vcl-assign-nullptr-after-deleting.patch

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