starmath/inc/ElementsDockingWindow.hxx    |    6 +++---
 starmath/source/ElementsDockingWindow.cxx |    7 +++++--
 2 files changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 5d41aca772cb9c4afd92ad408c66bd9642bb3952
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Jun 19 12:38:51 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Jun 19 16:56:13 2022 +0200

    cid#1506514 Uninitialized scalar field
    
    Change-Id: I777d9008289b2afb464d1002e8be32072c0a4501
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136099
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/starmath/inc/ElementsDockingWindow.hxx 
b/starmath/inc/ElementsDockingWindow.hxx
index 70ee4fafddc2..589694779f8d 100644
--- a/starmath/inc/ElementsDockingWindow.hxx
+++ b/starmath/inc/ElementsDockingWindow.hxx
@@ -40,7 +40,7 @@ class SmElementsControl
 
     SmDocShell*   mpDocShell;
     SmFormat      maFormat;
-    size_t        mnCurrentSetIndex;
+    int           mnCurrentSetIndex;
     sal_uInt16    m_nSmSyntaxVersion;
 
     bool          mbVerticalMode;
@@ -50,7 +50,7 @@ class SmElementsControl
     Link<OUString, void> maSelectHdlLink;
 
     void addElement(const OUString& aElementVisual, const OUString& 
aElementSource, const OUString& aHelpText);
-    void addElements(size_t nCategory);
+    void addElements(int nCategory);
 
     void build();
 
@@ -66,7 +66,7 @@ public:
     ~SmElementsControl();
 
     static const std::vector<TranslateId>& categories();
-    void setElementSetIndex(size_t nSetIndex);
+    void setElementSetIndex(int nSetIndex);
 
     void setVerticalMode(bool bVertical);
 
diff --git a/starmath/source/ElementsDockingWindow.cxx 
b/starmath/source/ElementsDockingWindow.cxx
index 4ded72c08f2c..b946cea28949 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -454,6 +454,7 @@ const std::vector<TranslateId>& 
SmElementsControl::categories()
 
 SmElementsControl::SmElementsControl(std::unique_ptr<weld::IconView> pIconView)
     : mpDocShell(new SmDocShell(SfxModelFlags::EMBEDDED_OBJECT))
+    , mnCurrentSetIndex(-1)
     , m_nSmSyntaxVersion(SM_MOD()->GetConfig()->GetDefaultSmSyntaxVersion())
     , mbVerticalMode(true)
     , mpIconView(std::move(pIconView))
@@ -540,7 +541,7 @@ OUString SmElementsControl::GetElementHelpText(const 
OUString& itemId)
     return weld::fromId<ElementData*>(itemId)->maHelpText;
 }
 
-void SmElementsControl::setElementSetIndex(size_t nSetIndex)
+void SmElementsControl::setElementSetIndex(int nSetIndex)
 {
     if (mnCurrentSetIndex == nSetIndex)
         return;
@@ -548,13 +549,15 @@ void SmElementsControl::setElementSetIndex(size_t 
nSetIndex)
     build();
 }
 
-void SmElementsControl::addElements(size_t nCategory)
+void SmElementsControl::addElements(int nCategory)
 {
     mpIconView->freeze();
     mpIconView->clear();
     mpIconView->set_item_width(0);
     maItemDatas.clear();
 
+    assert(nCategory >= 0 && o3tl::make_unsigned(nCategory) < 
s_a5CategoryDescriptions.size());
+
     const auto& [aElementsArray, aElementsArraySize] = 
s_a5CategoryDescriptions[nCategory];
 
     for (size_t i = 0; i < aElementsArraySize; i++)

Reply via email to