From 155fa38a71ff11e1617b1e3dfda770543df8eb1d Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Fri, 30 Sep 2011 17:18:35 -0700 Subject: [PATCH] Fix potential issue with the TextLayoutCache with glyphs - there may be a mapping of one char to many glyphs Change-Id: I48846d176d61dc8d8e513ca144fdf8ad805e63b7 --- core/jni/android/graphics/TextLayoutCache.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index 86ae7d2ae05f9..0d336eacf2431 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -620,7 +620,9 @@ void TextLayoutCacheValue::getGlyphsIndexAndCount(size_t start, size_t count, si return; } *outStartIndex = mLogClusters[start]; - *outGlyphsCount = mLogClusters[start + count - 1] - mLogClusters[start] + 1; + size_t endIndex = (start + count >= mAdvances.size()) ? + mGlyphs.size() : mLogClusters[start + count]; + *outGlyphsCount = endIndex - *outStartIndex; #if DEBUG_GLYPHS LOGD("getGlyphsIndexes - start=%d count=%d - startIndex=%d count=%d", start, count, *outStartIndex, *outGlyphsCount);