kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-rhbz-1775767-null-deref.patch

a977ad
From fd7b2f5fbbee23fc2ab9722fcd605921b7184113 Mon Sep 17 00:00:00 2001
a977ad
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
a977ad
Date: Thu, 28 Nov 2019 09:50:36 +0000
a977ad
Subject: [PATCH] rhbz#1775767 null deref
a977ad
a977ad
Change-Id: I6941055f9a02b36b5fe621fe89f49f62beb87e67
a977ad
---
a977ad
 include/sfx2/sidebar/Theme.hxx            |  2 +-
a977ad
 sfx2/source/sidebar/SidebarController.cxx |  9 +++--
a977ad
 sfx2/source/sidebar/Theme.cxx             | 43 ++++++++++++-----------
a977ad
 3 files changed, 29 insertions(+), 25 deletions(-)
a977ad
a977ad
diff --git a/include/sfx2/sidebar/Theme.hxx b/include/sfx2/sidebar/Theme.hxx
a977ad
index 16a4798..b7eaf88 100644
a977ad
--- a/include/sfx2/sidebar/Theme.hxx
a977ad
+++ b/include/sfx2/sidebar/Theme.hxx
a977ad
@@ -175,7 +175,7 @@ public:
a977ad
     virtual sal_Bool SAL_CALL hasPropertyByName (const OUString& rsName) override;
a977ad
 
a977ad
 private:
a977ad
-    static Theme& GetCurrentTheme();
a977ad
+    static Theme* GetCurrentTheme();
a977ad
 
a977ad
     std::vector<Image> maImages;
a977ad
     std::vector<Color> maColors;
a977ad
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
a977ad
index 0cad779..764d4e3 100644
a977ad
--- a/sfx2/source/sidebar/SidebarController.cxx
a977ad
+++ b/sfx2/source/sidebar/SidebarController.cxx
a977ad
@@ -258,9 +258,12 @@ void SAL_CALL SidebarController::disposing()
a977ad
         mpParentWindow = nullptr;
a977ad
     }
a977ad
 
a977ad
-    Theme::GetPropertySet()->removePropertyChangeListener(
a977ad
-        "",
a977ad
-        static_cast<css::beans::XPropertyChangeListener*>(this));
a977ad
+    Reference<beans::XPropertySet> xPropertySet = Theme::GetPropertySet();
a977ad
+    if (xPropertySet)
a977ad
+    {
a977ad
+        xPropertySet->removePropertyChangeListener("",
a977ad
+            static_cast<css::beans::XPropertyChangeListener*>(this));
a977ad
+    }
a977ad
 
a977ad
     maContextChangeUpdate.CancelRequest();
a977ad
     maAsynchronousDeckSwitch.CancelRequest();
a977ad
diff --git a/sfx2/source/sidebar/Theme.cxx b/sfx2/source/sidebar/Theme.cxx
a977ad
index bc6236d..1ef350e 100644
a977ad
--- a/sfx2/source/sidebar/Theme.cxx
a977ad
+++ b/sfx2/source/sidebar/Theme.cxx
a977ad
@@ -34,9 +34,10 @@ using namespace css::uno;
a977ad
 
a977ad
 namespace sfx2 { namespace sidebar {
a977ad
 
a977ad
-Theme& Theme::GetCurrentTheme()
a977ad
+Theme* Theme::GetCurrentTheme()
a977ad
 {
a977ad
-    return SfxGetpApp()->GetSidebarTheme();
a977ad
+    SfxApplication* pApp = SfxGetpApp();
a977ad
+    return pApp ? &pApp->GetSidebarTheme() : nullptr;
a977ad
 }
a977ad
 
a977ad
 Theme::Theme()
a977ad
@@ -67,8 +68,8 @@ Image Theme::GetImage (const ThemeItem eItem)
a977ad
     const PropertyType eType (GetPropertyType(eItem));
a977ad
     OSL_ASSERT(eType==PT_Image);
a977ad
     const sal_Int32 nIndex (GetIndex(eItem, eType));
a977ad
-    const Theme& rTheme (GetCurrentTheme());
a977ad
-    return rTheme.maImages[nIndex];
a977ad
+    const Theme* pTheme (GetCurrentTheme());
a977ad
+    return pTheme->maImages[nIndex];
a977ad
 }
a977ad
 
a977ad
 Color Theme::GetColor (const ThemeItem eItem)
a977ad
@@ -76,11 +77,11 @@ Color Theme::GetColor (const ThemeItem eItem)
a977ad
     const PropertyType eType (GetPropertyType(eItem));
a977ad
     OSL_ASSERT(eType==PT_Color || eType==PT_Paint);
a977ad
     const sal_Int32 nIndex (GetIndex(eItem, eType));
a977ad
-    const Theme& rTheme (GetCurrentTheme());
a977ad
+    const Theme* pTheme (GetCurrentTheme());
a977ad
     if (eType == PT_Color)
a977ad
-        return rTheme.maColors[nIndex];
a977ad
+        return pTheme->maColors[nIndex];
a977ad
     else if (eType == PT_Paint)
a977ad
-        return rTheme.maPaints[nIndex].GetColor();
a977ad
+        return pTheme->maPaints[nIndex].GetColor();
a977ad
     else
a977ad
         return COL_WHITE;
a977ad
 }
a977ad
@@ -90,8 +91,8 @@ const Paint& Theme::GetPaint (const ThemeItem eItem)
a977ad
     const PropertyType eType (GetPropertyType(eItem));
a977ad
     OSL_ASSERT(eType==PT_Paint);
a977ad
     const sal_Int32 nIndex (GetIndex(eItem, eType));
a977ad
-    const Theme& rTheme (GetCurrentTheme());
a977ad
-    return rTheme.maPaints[nIndex];
a977ad
+    const Theme* pTheme (GetCurrentTheme());
a977ad
+    return pTheme->maPaints[nIndex];
a977ad
 }
a977ad
 
a977ad
 const Wallpaper Theme::GetWallpaper (const ThemeItem eItem)
a977ad
@@ -104,8 +105,8 @@ sal_Int32 Theme::GetInteger (const ThemeItem eItem)
a977ad
     const PropertyType eType (GetPropertyType(eItem));
a977ad
     OSL_ASSERT(eType==PT_Integer);
a977ad
     const sal_Int32 nIndex (GetIndex(eItem, eType));
a977ad
-    const Theme& rTheme (GetCurrentTheme());
a977ad
-    return rTheme.maIntegers[nIndex];
a977ad
+    const Theme* pTheme (GetCurrentTheme());
a977ad
+    return pTheme->maIntegers[nIndex];
a977ad
 }
a977ad
 
a977ad
 bool Theme::GetBoolean (const ThemeItem eItem)
a977ad
@@ -113,28 +114,28 @@ bool Theme::GetBoolean (const ThemeItem eItem)
a977ad
     const PropertyType eType (GetPropertyType(eItem));
a977ad
     OSL_ASSERT(eType==PT_Boolean);
a977ad
     const sal_Int32 nIndex (GetIndex(eItem, eType));
a977ad
-    const Theme& rTheme (GetCurrentTheme());
a977ad
-    return rTheme.maBooleans[nIndex];
a977ad
+    const Theme* pTheme (GetCurrentTheme());
a977ad
+    return pTheme->maBooleans[nIndex];
a977ad
 }
a977ad
 
a977ad
 bool Theme::IsHighContrastMode()
a977ad
 {
a977ad
-    const Theme& rTheme (GetCurrentTheme());
a977ad
-    return rTheme.mbIsHighContrastMode;
a977ad
+    const Theme* pTheme (GetCurrentTheme());
a977ad
+    return pTheme->mbIsHighContrastMode;
a977ad
 }
a977ad
 
a977ad
 void Theme::HandleDataChange()
a977ad
 {
a977ad
-    Theme& rTheme (GetCurrentTheme());
a977ad
+    Theme* pTheme (GetCurrentTheme());
a977ad
 
a977ad
-    if ( ! rTheme.mbIsHighContrastModeSetManually)
a977ad
+    if (!pTheme->mbIsHighContrastModeSetManually)
a977ad
     {
a977ad
         // Do not modify mbIsHighContrastMode when it was manually set.
a977ad
-        GetCurrentTheme().mbIsHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
a977ad
-        rTheme.maRawValues[Bool_IsHighContrastModeActive] <<= GetCurrentTheme().mbIsHighContrastMode;
a977ad
+        GetCurrentTheme()->mbIsHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
a977ad
+        pTheme->maRawValues[Bool_IsHighContrastModeActive] <<= GetCurrentTheme()->mbIsHighContrastMode;
a977ad
     }
a977ad
 
a977ad
-    GetCurrentTheme().UpdateTheme();
a977ad
+    GetCurrentTheme()->UpdateTheme();
a977ad
 }
a977ad
 
a977ad
 void Theme::InitializeTheme()
a977ad
@@ -369,7 +370,7 @@ void SAL_CALL Theme::disposing()
a977ad
 
a977ad
 Reference<beans::XPropertySet> Theme::GetPropertySet()
a977ad
 {
a977ad
-    return Reference<beans::XPropertySet>(static_cast<XWeak*>(&GetCurrentTheme()), UNO_QUERY);
a977ad
+    return Reference<beans::XPropertySet>(static_cast<XWeak*>(GetCurrentTheme()), UNO_QUERY);
a977ad
 }
a977ad
 
a977ad
 Reference<beans::XPropertySetInfo> SAL_CALL Theme::getPropertySetInfo()
a977ad
-- 
a977ad
2.20.1
a977ad