vcl/source/app/salvtables.cxx    |    2 ++
 vcl/source/treelist/treelist.cxx |    6 ++++++
 2 files changed, 8 insertions(+)

New commits:
commit ea046739f0e0b1c5a42ff8e1df399c0159e87fdd
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Mon Jun 20 10:27:26 2022 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Tue Jun 21 13:37:58 2022 +0200

    Fix crash when no valid EntryDescriptor found
    
    When opening macro run dlg, the last selected entry is displayed again.
    When no entry was found, a crash occured in some situations
    (GetLastEntryDescriptor() returned garbage).
    
    Initialize m_aLastEntryDesc properly, and make sure the method returns
    when no last selected macro was found.
    
    Also fix some nullptr crashes which occurred during UITests
    
    Backport note: Part of this was already backported in 
8abd6a27f0d80730596a20e8d234df9dec530571
    
    Change-Id: I7bd1a0b8824725f9935876ae26d8222410a3bc25
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136140
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>

diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 4231a572d81c..ea0120524027 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4276,6 +4276,8 @@ public:
     virtual OUString get_id(const weld::TreeIter& rIter) const override
     {
         const SalInstanceTreeIter& rVclIter = static_cast<const 
SalInstanceTreeIter&>(rIter);
+        if (!rVclIter.iter)
+            return OUString();
         const OUString* pStr = static_cast<const 
OUString*>(rVclIter.iter->GetUserData());
         if (pStr)
             return *pStr;
diff --git a/vcl/source/treelist/treelist.cxx b/vcl/source/treelist/treelist.cxx
index 69a3284a495c..9f5b0b1db499 100644
--- a/vcl/source/treelist/treelist.cxx
+++ b/vcl/source/treelist/treelist.cxx
@@ -101,6 +101,8 @@ bool SvTreeList::IsEntryVisible( const SvListView* pView, 
SvTreeListEntry* pEntr
 
 sal_uInt16 SvTreeList::GetDepth( const SvTreeListEntry* pEntry ) const
 {
+    if (!pEntry)
+        return 0;
     DBG_ASSERT(pEntry && pEntry!=pRootItem.get(),"GetDepth:Bad Entry");
     sal_uInt16 nDepth = 0;
     while( pEntry && pEntry->pParent != pRootItem.get() )
@@ -1562,6 +1564,8 @@ SvTreeListEntries& SvTreeList::GetChildList( 
SvTreeListEntry* pParent )
 
 const SvTreeListEntry* SvTreeList::GetParent( const SvTreeListEntry* pEntry ) 
const
 {
+    if (!pEntry)
+        return nullptr;
     const SvTreeListEntry* pParent = pEntry->pParent;
     if (pParent == pRootItem.get())
         pParent = nullptr;
@@ -1570,6 +1574,8 @@ const SvTreeListEntry* SvTreeList::GetParent( const 
SvTreeListEntry* pEntry ) co
 
 SvTreeListEntry* SvTreeList::GetParent( SvTreeListEntry* pEntry )
 {
+    if (!pEntry)
+        return nullptr;
     SvTreeListEntry* pParent = pEntry->pParent;
     if (pParent == pRootItem.get())
         pParent = nullptr;

Reply via email to