mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 765831 - Part 4: Clamp string lengths passed to getTextBeforeCursor/getTextAfterCursor. r=blassey
This commit is contained in:
parent
899a4bbb58
commit
7ea36bae56
@ -256,7 +256,16 @@ public class GeckoInputConnection
|
||||
|
||||
@Override
|
||||
public CharSequence getTextBeforeCursor(int length, int flags) {
|
||||
clampSelection();
|
||||
// Avoid underrunning text buffer.
|
||||
Span selection = clampSelection();
|
||||
if (length > selection.start) {
|
||||
length = selection.start;
|
||||
}
|
||||
|
||||
if (length < 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return super.getTextBeforeCursor(length, flags);
|
||||
}
|
||||
|
||||
@ -268,7 +277,17 @@ public class GeckoInputConnection
|
||||
|
||||
@Override
|
||||
public CharSequence getTextAfterCursor(int length, int flags) {
|
||||
clampSelection();
|
||||
// Avoid overrunning text buffer.
|
||||
Span selection = clampSelection();
|
||||
int contentLength = getEditable().length();
|
||||
if (selection.end + length > contentLength) {
|
||||
length = contentLength - selection.end;
|
||||
}
|
||||
|
||||
if (length < 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return super.getTextAfterCursor(length, flags);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user