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>
This commit is contained in:
committed by
Michael Stahl
parent
44af200f59
commit
087a6b0cf3
@@ -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 );
|
||||
|
||||
|
Reference in New Issue
Block a user