summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-11-11 18:23:15 +0100
committerMichael Stahl <michael.stahl@cib.de>2019-11-12 13:04:04 +0100
commit087a6b0cf34ab64801dba5aa7ff3d7ea53c2272b (patch)
treea9e83b99b65c92174a3ae2043385ef1f5a7b258c /toolkit
parent44af200f59f37c73a6dea3bcbee61a1ebb24f99a (diff)
toolkit: UnoEditControl::insertText() assert on invalid index
... in replaceAt(): if the selection that is passed in is invalid, throw an exception. This obviously isn't thread-safe but naively adding a GetMutex() guard quickly deadlocks against SolarMutex; why does it use its own mutex? Reproduces when installing APSO 1.2.5 and starting the Python REPL. Change-Id: I4fb16ab820641f1a031537b0c4d6f8664d67dc0c Reviewed-on: https://gerrit.libreoffice.org/82460 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/controls/unocontrols.cxx7
1 files changed, 6 insertions, 1 deletions
diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx
index e2ebbf77ed41..cbb04926bd95 100644
--- a/toolkit/source/controls/unocontrols.cxx
+++ b/toolkit/source/controls/unocontrols.cxx
@@ -327,6 +327,12 @@ void UnoEditControl::insertText( const awt::Selection& rSel, const OUString& rNe
awt::Selection aSelection( rSel );
lcl_normalize( aSelection );
+ OUString aOldText = getText();
+ if (aSelection.Min < 0 || aOldText.getLength() < aSelection.Max)
+ {
+ throw lang::IllegalArgumentException();
+ }
+
// preserve the selection resp. cursor position
awt::Selection aNewSelection( getSelection() );
#ifdef ALSO_PRESERVE_COMPLETE_SELECTION
@@ -341,7 +347,6 @@ void UnoEditControl::insertText( const awt::Selection& rSel, const OUString& rNe
aNewSelection.Min = aNewSelection.Max;
#endif
- OUString aOldText = getText();
OUString aNewText = aOldText.replaceAt( aSelection.Min, aSelection.Max - aSelection.Min, rNewText );
setText( aNewText );