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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/TextIterator.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
« no previous file with comments | « third_party/WebKit/Source/core/editing/iterators/TextIterator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
index 57b892e70f62bfee14061809fc1071a3eb280158..2867b57a22c7a5eaba3aa3fd514105236782417a 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -1115,7 +1115,10 @@ bool TextIteratorAlgorithm<Strategy>::isBetweenSurrogatePair(int position) const
template <typename Strategy>
int TextIteratorAlgorithm<Strategy>::copyTextTo(ForwardsTextBuffer* 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;
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/iterators/TextIterator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698