summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-09-10 09:17:18 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-09-10 10:32:49 +0200
commitf6a7c887956048ccaef5df610db28679806a6ebf (patch)
treef7710765546c56df13072059aa7fd9157d9f805e /vcl/source/window
parentba4b3d5f7a0fe8d0d985e98897e041d59093d8b0 (diff)
Guard against lone mnemonic prefix at end of key
For --with-lang=am, CppunitTest_sw_dialogs_test hit > cppunittester: include/rtl/ustring.hxx:764: sal_Unicode rtl::OUString::operator[](sal_Int32) const: Assertion `index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength())' failed. at > #4 0x00007fffcff543df in rtl::OUString::operator[](int) const (this=0x7ffff3538f40, index=2) at include/rtl/ustring.hxx:764 > #5 0x00007fffd0381b24 in MnemonicGenerator::ImplFindMnemonic(rtl::OUString const&) (this=0x7ffff371c820, rKey="በ_") at vcl/source/window/mnemonic.cxx:67 > #6 0x00007fffd038210c in MnemonicGenerator::RegisterMnemonic(rtl::OUString const&) (this=0x7ffff371c820, rKey="በ_") at vcl/source/window/mnemonic.cxx:89 > #7 0x00007fffb244fa77 in (anonymous namespace)::GtkInstanceBuilder::GenerateMissingMnemonics() (this=0x611000133840) at vcl/unx/gtk3/gtk3gtkinst.cxx:15799 > #8 0x00007fffb2431811 in (anonymous namespace)::GtkInstanceBuilder::GtkInstanceBuilder(_GtkWidget*, rtl::OUString const&, rtl::OUString const&, SystemChildWindow*) (this=0x611000133840, pParent=0x625000260460 [GtkBox], rUIRoot="file:///.../instdir/share/config/soffice.cfg/", rUIFile="modules/swriter/ui/frmtypepage.ui", pInterimGlue=0x0) at vcl/unx/gtk3/gtk3gtkinst.cxx:15784 > #9 0x00007fffb243001a in GtkInstance::CreateBuilder(weld::Widget*, rtl::OUString const&, rtl::OUString const&) (this=0x614000005a40, pParent=0x61700001ef18, rUIRoot="file:///.../instdir/share/config/soffice.cfg/", rUIFile="modules/swriter/ui/frmtypepage.ui") at vcl/unx/gtk3/gtk3gtkinst.cxx:16333 [...] apparently caused by > #. ytvmN > #: sw/uiconfig/swriter/ui/frmtypepage.ui:617 > msgctxt "frmtypepage|horibyft" > msgid "b_y" > msgstr "በ_" in translations/source/am/sw/messages.po Change-Id: Ie02ed94d159d957984fb3cd91ed6608a6148a570 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102356 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/mnemonic.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/vcl/source/window/mnemonic.cxx b/vcl/source/window/mnemonic.cxx
index 16b2f4015778..42a3d4ad258e 100644
--- a/vcl/source/window/mnemonic.cxx
+++ b/vcl/source/window/mnemonic.cxx
@@ -27,6 +27,7 @@
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <rtl/character.hxx>
+#include <sal/log.hxx>
using namespace ::com::sun::star;
@@ -64,6 +65,10 @@ sal_Unicode MnemonicGenerator::ImplFindMnemonic( const OUString& rKey )
sal_Int32 nIndex = 0;
while ( (nIndex = rKey.indexOf( m_cMnemonic, nIndex )) != -1 )
{
+ if (nIndex == rKey.getLength() - 1) {
+ SAL_WARN("vcl", "key \"" << rKey << "\" ends in lone mnemonic prefix");
+ break;
+ }
sal_Unicode cMnemonic = rKey[ nIndex+1 ];
if ( cMnemonic != m_cMnemonic )
return cMnemonic;