[Libreoffice-commits] core.git: toolkit/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 12 12:05:23 UTC 2019
toolkit/source/controls/unocontrols.cxx | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
New commits:
commit 087a6b0cf34ab64801dba5aa7ff3d7ea53c2272b
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Nov 11 18:23:15 2019 +0100
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Nov 12 13:04:04 2019 +0100
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 at cib.de>
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 );
More information about the Libreoffice-commits
mailing list