mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix potential NULL dereference in Paragraph.getWordBoundary. (#2679)
Can happen when calling getWordBoundary on an empty Paragraph.
This commit is contained in:
parent
57edc534d6
commit
ce4bb9e16d
@ -157,7 +157,7 @@ Dart_Handle Paragraph::getPositionForOffset(const Offset& offset) {
|
||||
|
||||
Dart_Handle Paragraph::getWordBoundary(unsigned offset) {
|
||||
String text;
|
||||
int start, end;
|
||||
int start = 0, end = 0;
|
||||
|
||||
for (RenderObject* object = m_renderView.get(); object; object = object->nextInPreOrder()) {
|
||||
if (!object->isText())
|
||||
@ -167,10 +167,12 @@ Dart_Handle Paragraph::getWordBoundary(unsigned offset) {
|
||||
}
|
||||
|
||||
TextBreakIterator* it = wordBreakIterator(text, 0, text.length());
|
||||
end = it->following(offset);
|
||||
if (end < 0)
|
||||
end = it->last();
|
||||
start = it->previous();
|
||||
if (it) {
|
||||
end = it->following(offset);
|
||||
if (end < 0)
|
||||
end = it->last();
|
||||
start = it->previous();
|
||||
}
|
||||
|
||||
Dart_Handle result = Dart_NewList(2);
|
||||
Dart_ListSetAt(result, 0, ToDart(start));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user