Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef090410 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Make the range checking of BaseInputConnection#setSelection stricter

With this change, setSelection will not cause java.lang.IndexOutOfBoundsException
even if a negative index is specified.

Bug: 8841916
Change-Id: Ib62a6ba235f80b7495fefb2e5cc2d5357d804310
parent 43200530
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -484,10 +484,10 @@ public class BaseInputConnection implements InputConnection {
        final Editable content = getEditable();
        if (content == null) return false;
        int len = content.length();
        if (start > len || end > len) {
        if (start > len || end > len || start < 0 || end < 0) {
            // If the given selection is out of bounds, just ignore it.
            // Most likely the text was changed out from under the IME,
            // the the IME is going to have to update all of its state
            // and the IME is going to have to update all of its state
            // anyway.
            return true;
        }