vcl/source/uitest/uiobject.cxx |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 9b98856c59707037cc25ec7f2dae975bc269901d
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Mar 27 21:52:04 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Mar 28 06:43:24 2024 +0100

    prevent SEGV in ToolBoxUIObject::get_state
    
    if we call it while it has no current item id
    
    Change-Id: I0e62d35b24f18104f6fd55c129fd7f91f2449e5b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165433
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 24b11ecb8556..2671a9145436 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -1696,9 +1696,10 @@ OUString ToolBoxUIObject::get_action(VclEventId nEvent) 
const
 StringMap ToolBoxUIObject::get_state()
 {
     StringMap aMap = WindowUIObject::get_state();
-    aMap["CurrSelectedItemID"] = 
OUString::number(sal_uInt16(mxToolBox->GetCurItemId()));
-    aMap["CurrSelectedItemText"] = 
mxToolBox->GetItemText(mxToolBox->GetCurItemId());
-    aMap["CurrSelectedItemCommand"] = 
mxToolBox->GetItemCommand(mxToolBox->GetCurItemId());
+    ToolBoxItemId nCurItemId = mxToolBox->GetCurItemId();
+    aMap["CurrSelectedItemID"] = OUString::number(sal_uInt16(nCurItemId));
+    aMap["CurrSelectedItemText"] = nCurItemId ? 
mxToolBox->GetItemText(nCurItemId) : "";
+    aMap["CurrSelectedItemCommand"] = nCurItemId ? 
mxToolBox->GetItemCommand(nCurItemId) : "";
     aMap["ItemCount"] = OUString::number(mxToolBox->GetItemCount());
     return aMap;
 }

Reply via email to