Chromium Code Reviews| Index: ui/gfx/text_elider.cc |
| diff --git a/ui/gfx/text_elider.cc b/ui/gfx/text_elider.cc |
| index 1bf85d4936761a22cf3351c4fa0e871abbf518bd..43134e77cf75c7f1c6f8b46c66edf774e752eacf 100644 |
| --- a/ui/gfx/text_elider.cc |
| +++ b/ui/gfx/text_elider.cc |
| @@ -17,6 +17,7 @@ |
| #include "base/i18n/char_iterator.h" |
| #include "base/i18n/rtl.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/numerics/safe_conversions.h" |
| #include "base/strings/string_split.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/sys_string_conversions.h" |
| @@ -146,8 +147,12 @@ size_t StringSlicer::FindValidBoundaryBefore(size_t index) const { |
| size_t StringSlicer::FindValidBoundaryAfter(size_t index) const { |
| DCHECK_LE(index, text_.length()); |
| - if (index != text_.length()) |
| - U16_SET_CP_LIMIT(text_.data(), 0, index, text_.length()); |
| + if (index != text_.length()) { |
| + int32_t text_index = base::checked_cast<int32_t>(index); |
| + int32_t text_length = base::checked_cast<int32_t>(text_.length()); |
| + U16_SET_CP_LIMIT(text_.data(), 0, text_index, text_length); |
| + index = base::checked_cast<size_t>(text_index); |
|
Peter Kasting
2014/10/29 19:17:26
How about this:
if (index == text_.length())
|
| + } |
| return index; |
| } |