From 78b868ff42cc368c45f851443678a822560dc266 Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Tue, 17 May 2011 19:48:57 -0700 Subject: [PATCH] Fix bug #4441002 Crash in SkPathEffectGlue::OneD_constructor - take care of empty strings in TextLayoutCache when computing advances/glyphs with Harfbuzz Change-Id: I8eb5f632feb7a86e5c4a6db03d073c4b7d859dbc --- core/jni/android/graphics/TextLayoutCache.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index 26aa7d9af7ccb..a5b200618e3d7 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -547,6 +547,25 @@ void TextLayoutCacheValue::computeRunValuesWithHarfbuzz(SkPaint* paint, const UC LOGD(" -- isDevKernText=%d", paint->isDevKernText()); #endif + if (shaperItem.advances == NULL || shaperItem.num_glyphs == 0) { +#if DEBUG_GLYPHS + LOGD("HARFBUZZ -- advances array is empty or num_glypth = 0"); +#endif + for (size_t i = 0; i < count; i++) { + outAdvances[i] = 0; + } + *outTotalAdvance = 0; + + if (outGlyphs) { + *outGlyphsCount = 0; + *outGlyphs = new jchar[0]; + } + + // Cleaning + deleteGlyphArrays(&shaperItem); + HB_FreeFace(shaperItem.face); + return; + } // Get Advances and their total jfloat totalAdvance = outAdvances[0] = HBFixedToFloat(shaperItem.advances[shaperItem.log_clusters[0]]); for (size_t i = 1; i < count; i++) {