Commit 43cfa30f authored by Tessa Nijssen's avatar Tessa Nijssen Committed by Commit Bot

FrameSelection::SelectWordAroundCaret(): Check Start and End for Null

EphemeralRange crashes when it receives a null position. If a
textfield is empty, the start and/or end of the word around the caret
may be null. This causes the renderer to crash.

Add a check that the start and end positions are not null before
passing them in to EphemeralRange.

Bug: 872443
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I7156bb99b53134d076359f9ea320b5a5cdbe5bc0
Reviewed-on: https://chromium-review.googlesource.com/1169584
Commit-Queue: Tessa Nijssen <tnijssen@google.com>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582264}
parent 0c1e8e53
...@@ -1096,6 +1096,13 @@ bool FrameSelection::SelectWordAroundCaret() { ...@@ -1096,6 +1096,13 @@ bool FrameSelection::SelectWordAroundCaret() {
// for avoiding unnecessary canonicalization. // for avoiding unnecessary canonicalization.
VisiblePosition start = StartOfWord(position, word_side); VisiblePosition start = StartOfWord(position, word_side);
VisiblePosition end = EndOfWord(position, word_side); VisiblePosition end = EndOfWord(position, word_side);
// TODO(editing-dev): |StartOfWord()| and |EndOfWord()| should not make null
// for non-null parameter.
// See http://crbug.com/872443
if (start.DeepEquivalent().IsNull() || end.DeepEquivalent().IsNull())
continue;
String text = String text =
PlainText(EphemeralRange(start.DeepEquivalent(), end.DeepEquivalent())); PlainText(EphemeralRange(start.DeepEquivalent(), end.DeepEquivalent()));
if (!text.IsEmpty() && !IsSeparator(text.CharacterStartingAt(0))) { if (!text.IsEmpty() && !IsSeparator(text.CharacterStartingAt(0))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment