cui/source/dialogs/toolbarmodedlg.cxx | 7 ++++++- cui/source/dialogs/uitabpage.cxx | 4 +++- cui/source/inc/uitabpage.hxx | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-)
New commits: commit 96eb56161362603026eb17e5fa8d9d68d5a1a7f8 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri May 2 08:37:46 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Fri May 2 12:18:37 2025 +0200 cid#1646782 Negative array index read Change-Id: I0c8b1ab1fdc01999822042c73f37268a77b1b6b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184888 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/cui/source/dialogs/toolbarmodedlg.cxx b/cui/source/dialogs/toolbarmodedlg.cxx index 901043f3500e..2b259e9701cc 100644 --- a/cui/source/dialogs/toolbarmodedlg.cxx +++ b/cui/source/dialogs/toolbarmodedlg.cxx @@ -49,7 +49,12 @@ void ToolbarmodeDialog::ActivatePage(const OUString& rPage) IMPL_LINK(ToolbarmodeDialog, OnApplyClick, weld::Button&, rButton, void) { UITabPage* pUITabPage = static_cast<UITabPage*>(GetCurTabPage()); - const OUString& sCmd = pUITabPage->GetSelectedMode(); + OUString sCmd = pUITabPage->GetSelectedMode(); + if (sCmd.isEmpty()) + { + SAL_WARN("cui.dialogs", "ToolbarmodeDialog: no mode selected"); + return; + } //apply to all except current module if (&rButton == m_xResetBtn.get()) // Apply to All diff --git a/cui/source/dialogs/uitabpage.cxx b/cui/source/dialogs/uitabpage.cxx index 7079d5cf4e1a..27bc7be648e7 100644 --- a/cui/source/dialogs/uitabpage.cxx +++ b/cui/source/dialogs/uitabpage.cxx @@ -128,9 +128,11 @@ int UITabPage::GetActiveRadioButton() return -1; } -const OUString& UITabPage::GetSelectedMode() +OUString UITabPage::GetSelectedMode() { int i = GetActiveRadioButton(); + if (i < 0) + return OUString(); return std::get<1>(UIMODES_ARRAY[i]); } diff --git a/cui/source/inc/uitabpage.hxx b/cui/source/inc/uitabpage.hxx index 1851243a69d7..f12339df2297 100644 --- a/cui/source/inc/uitabpage.hxx +++ b/cui/source/inc/uitabpage.hxx @@ -32,7 +32,7 @@ public: static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet); - const OUString& GetSelectedMode(); + OUString GetSelectedMode(); static OUString GetCurrentApp(); };