From 72ab39455f2fe587116066d5ec66d75cd89f0114 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 18 Feb 2016 10:27:38 -0800 Subject: [PATCH] Disable hyphenation when word overlaps style boundary In cases when a word (as defined by the ICU break iterator) overlaps a style boundary, the returned wordStart can be extend before the range currently being measured for layout. When we try to hyphenate the resulting substrings, we get a negative range, which crashes. This patch disables hyphenation in this case. Bug: 27237112 Change-Id: I76d04b39dd3b4d6d267aaaf4bebc9ab361891646 --- engine/src/flutter/libs/minikin/LineBreaker.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/libs/minikin/LineBreaker.cpp b/engine/src/flutter/libs/minikin/LineBreaker.cpp index 9cf07d5d9e..22c39547ae 100644 --- a/engine/src/flutter/libs/minikin/LineBreaker.cpp +++ b/engine/src/flutter/libs/minikin/LineBreaker.cpp @@ -174,7 +174,8 @@ float LineBreaker::addStyleRun(MinikinPaint* paint, const FontCollection* typefa if (paint != nullptr && mHyphenator != nullptr && mHyphenationFrequency != kHyphenationFrequency_None && !wordEndsInHyphen && !temporarilySkipHyphenation && - wordEnd > wordStart && wordEnd - wordStart <= LONGEST_HYPHENATED_WORD) { + wordStart >= start && wordEnd > wordStart && + wordEnd - wordStart <= LONGEST_HYPHENATED_WORD) { mHyphenator->hyphenate(&mHyphBuf, &mTextBuf[wordStart], wordEnd - wordStart); #if VERBOSE_DEBUG std::string hyphenatedString;