Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 5101d25

Browse files
committed
add protection for textediting composition
1 parent 5a49be6 commit 5101d25

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Runtime/service/text_input.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ public TextEditingValue compose(string composeText) {
345345
D.assert(!string.IsNullOrEmpty(composeText));
346346
var composeStart = this.composing == TextRange.empty ? this.selection.start : this.composing.start;
347347
var lastComposeEnd = this.composing == TextRange.empty ? this.selection.end : this.composing.end;
348+
349+
composeStart = Mathf.Clamp(composeStart, 0, this.text.Length);
350+
lastComposeEnd = Mathf.Clamp(lastComposeEnd, 0, this.text.Length);
348351
var newText = this.text.Substring(0, composeStart) + composeText + this.text.Substring(lastComposeEnd);
349352
var componseEnd = composeStart + composeText.Length;
350353
return new TextEditingValue(

0 commit comments

Comments
 (0)