Blame SOURCES/0046-fdo-66984-Define-an-assignment-operator-to-prevent-d.patch

f0633d
From 1d33b1de2b9eeef0043c057bbfa539ab1e7c3238 Mon Sep 17 00:00:00 2001
f0633d
From: Kohei Yoshida <kohei.yoshida@collabora.com>
f0633d
Date: Fri, 6 Dec 2013 19:44:21 -0500
f0633d
Subject: [PATCH 046/109] fdo#66984: Define an assignment operator to prevent
f0633d
 double deletion.
f0633d
MIME-Version: 1.0
f0633d
Content-Type: text/plain; charset=UTF-8
f0633d
Content-Transfer-Encoding: 8bit
f0633d
f0633d
The code path was assigning one ScDPObject to another via assignment,
f0633d
but we didn't define one. So we were using the compiler generated
f0633d
assignment which only shallow-copies data members, which ultimately
f0633d
caused double-deletion of one of its data members.
f0633d
f0633d
Change-Id: Ie98d0789e51aebff683dbcc0e533a9a0a87943d5
f0633d
(cherry picked from commit bd976e5b070ec68a4f842190db4d0c1ea0e93428)
f0633d
Reviewed-on: https://gerrit.libreoffice.org/6966
f0633d
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
f0633d
Tested-by: Caolán McNamara <caolanm@redhat.com>
f0633d
---
f0633d
 sc/inc/dpobject.hxx              |  3 +++
f0633d
 sc/source/core/data/dpobject.cxx | 49 +++++++++++++++++++++++++++++++++++-----
f0633d
 2 files changed, 46 insertions(+), 6 deletions(-)
f0633d
f0633d
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
f0633d
index 8505a53..06d4957 100644
f0633d
--- a/sc/inc/dpobject.hxx
f0633d
+++ b/sc/inc/dpobject.hxx
f0633d
@@ -118,11 +118,14 @@ public:
f0633d
     ScDPObject(const ScDPObject& r);
f0633d
     ~ScDPObject();
f0633d
 
f0633d
+    ScDPObject& operator= (const ScDPObject& r);
f0633d
+
f0633d
     void EnableGetPivotData(bool b);
f0633d
 
f0633d
     void                SetAllowMove(bool bSet);
f0633d
 
f0633d
     void                InvalidateData();
f0633d
+    void Clear();
f0633d
     void ClearTableData();
f0633d
     void ReloadGroupTableData();
f0633d
 
f0633d
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
f0633d
index 677ccd5..169231a 100644
f0633d
--- a/sc/source/core/data/dpobject.cxx
f0633d
+++ b/sc/source/core/data/dpobject.cxx
f0633d
@@ -354,12 +354,34 @@ ScDPObject::ScDPObject(const ScDPObject& r) :
f0633d
 
f0633d
 ScDPObject::~ScDPObject()
f0633d
 {
f0633d
-    delete pOutput;
f0633d
-    delete pSaveData;
f0633d
-    delete pSheetDesc;
f0633d
-    delete pImpDesc;
f0633d
-    delete pServDesc;
f0633d
-    ClearTableData();
f0633d
+    Clear();
f0633d
+}
f0633d
+
f0633d
+ScDPObject& ScDPObject::operator= (const ScDPObject& r)
f0633d
+{
f0633d
+    Clear();
f0633d
+
f0633d
+    pDoc = r.pDoc;
f0633d
+    aTableName = r.aTableName;
f0633d
+    aTableTag = r.aTableTag;
f0633d
+    aOutRange = r.aOutRange;
f0633d
+    mnAutoFormatIndex = r.mnAutoFormatIndex;
f0633d
+    nHeaderRows = r.nHeaderRows;
f0633d
+    mbHeaderLayout = r.mbHeaderLayout;
f0633d
+    bAllowMove = false;
f0633d
+    bSettingsChanged = false;
f0633d
+    mbEnableGetPivotData = r.mbEnableGetPivotData;
f0633d
+
f0633d
+    if (r.pSaveData)
f0633d
+        pSaveData = new ScDPSaveData(*r.pSaveData);
f0633d
+    if (r.pSheetDesc)
f0633d
+        pSheetDesc = new ScSheetSourceDesc(*r.pSheetDesc);
f0633d
+    if (r.pImpDesc)
f0633d
+        pImpDesc = new ScImportSourceDesc(*r.pImpDesc);
f0633d
+    if (r.pServDesc)
f0633d
+        pServDesc = new ScDPServiceDesc(*r.pServDesc);
f0633d
+
f0633d
+    return *this;
f0633d
 }
f0633d
 
f0633d
 void ScDPObject::EnableGetPivotData(bool b)
f0633d
@@ -780,6 +802,21 @@ void ScDPObject::InvalidateData()
f0633d
     bSettingsChanged = true;
f0633d
 }
f0633d
 
f0633d
+void ScDPObject::Clear()
f0633d
+{
f0633d
+    delete pOutput;
f0633d
+    delete pSaveData;
f0633d
+    delete pSheetDesc;
f0633d
+    delete pImpDesc;
f0633d
+    delete pServDesc;
f0633d
+    pOutput = NULL;
f0633d
+    pSaveData = NULL;
f0633d
+    pSheetDesc = NULL;
f0633d
+    pImpDesc = NULL;
f0633d
+    pServDesc = NULL;
f0633d
+    ClearTableData();
f0633d
+}
f0633d
+
f0633d
 void ScDPObject::ClearTableData()
f0633d
 {
f0633d
     ClearSource();
f0633d
-- 
f0633d
1.8.4.2
f0633d