Commit f8d46f72 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make ShapeResult::CountGraphemesInCluster() not to crash with empty string

This patch changes |ShapeResult::CountGraphemesInCluster()| not to crash
when specified substring is empty by avoiding null reference of
|CursorMovementIterator|.

Note: This is a speculative patch because I could not reproduce locally.
ClusterFuzz will check whether this patch is effective or not.

Bug: 1071423
Change-Id: I6807ead3cb05f11d2ff663de8f5675aee524b5a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2402467
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805664}
parent 68de0d4d
......@@ -756,6 +756,8 @@ unsigned ShapeResult::CountGraphemesInCluster(base::span<const UChar> str,
uint16_t length = end_index - start_index;
TextBreakIterator* cursor_pos_iterator =
CursorMovementIterator(str.subspan(start_index, length));
if (!cursor_pos_iterator)
return 0;
int cursor_pos = cursor_pos_iterator->current();
int num_graphemes = -1;
......
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