Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Unified Diff: third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp

Issue 1691053004: Make copyTextTo() of text iterators check the length parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp
index bc18302863ca7edc1c9c6ebb295cb7f4ce958d14..d18b40333873ffd79331588b2c6786a1e14d8758 100644
--- a/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp
@@ -413,7 +413,10 @@ bool SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::isBetweenSurrogatePair(
template <typename Strategy>
int SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::copyTextTo(BackwardsTextBuffer* output, int position, int minLength) const
{
- int copiedLength = isBetweenSurrogatePair(position + minLength) ? minLength + 1 : minLength;
+ int end = std::min(length(), position + minLength);
+ if (isBetweenSurrogatePair(end))
+ ++end;
+ int copiedLength = end - position;
copyCodeUnitsTo(output, position, copiedLength);
return copiedLength;
}

Powered by Google App Engine
This is Rietveld 408576698