Skip to content

bug(android): performLeftDeletions triggering StringIndexOutOfBoundsException #15612

@sentry

Description

@sentry

Sentry Issue: KEYMAN-ANDROID-7A3

StringIndexOutOfBoundsException: begin 0, end -1, length 1
    at com.keyman.engine.KMKeyboardJSHandler.performLeftDeletions(KMKeyboardJSHandler.java:346)
    at com.keyman.engine.KMKeyboardJSHandler.-$$Nest$smperformLeftDeletions
    at com.keyman.engine.KMKeyboardJSHandler$1.run(KMKeyboardJSHandler.java:219)
...
(9 additional frame(s) were not displayed)

I'm not seeing keyboard details to trigger this.
Conceptually, it seems like given a context of 1 character, and attempting to do 2 left deletions we then get to:

int start = 0;
int end = 1-(2+0) = -1;
CharSequence expectedChars;
try {
  expectedChars = charsBackup.subSequence(start, end);

which throws because of a negative index.

// Chop dn+numPairs code points from the end of charsBackup
// subSequence indices are start(inclusive) to end(exclusive)
int start = 0;
int end = charsBackup.length() - (dn + numPairs);
CharSequence expectedChars;
try {
expectedChars = charsBackup.subSequence(start, end);

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions