fonts: Use empty glyphs on cache miss.

In case of a cache miss, we end up using a glyph with garbage memory
which can result in arbitrary memory allocations for generating images
for these glyphs. Use empty glyphs instead.

R=herb@google.com

Bug: skia:7913
Change-Id: Ie81b006a6872e077f9fd37e0a5751750c66f9ecb
Reviewed-on: https://skia-review.googlesource.com/128701
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Khusal Sagar <khushalsagar@chromium.org>
This commit is contained in:
Khushal 2018-05-16 16:07:24 -07:00 committed by Skia Commit-Bot
parent 53ea91139a
commit 2d2fedd25d
2 changed files with 5 additions and 1 deletions

View File

@ -700,6 +700,8 @@ void SkStrikeClient::generateFontMetrics(const SkTypefaceProxy& typefaceProxy,
SkDebugf("generateFontMetrics: %s\n", rec.dump().c_str());
SkStrikeCache::Dump();
SkDEBUGFAIL("GlyphCacheMiss");
sk_bzero(metrics, sizeof(*metrics));
}
void SkStrikeClient::generateMetricsAndImage(const SkTypefaceProxy& typefaceProxy,
@ -710,6 +712,8 @@ void SkStrikeClient::generateMetricsAndImage(const SkTypefaceProxy& typefaceProx
SkDebugf("generateMetricsAndImage: %s\n", rec.dump().c_str());
SkStrikeCache::Dump();
SkDEBUGFAIL("GlyphCacheMiss");
glyph->zeroMetrics();
}
void SkStrikeClient::generatePath(const SkTypefaceProxy& typefaceProxy,

View File

@ -39,7 +39,7 @@ void SkScalerContextProxy::generateImage(const SkGlyph& glyph) {
bool SkScalerContextProxy::generatePath(SkGlyphID glyphID, SkPath* path) {
fClient->generatePath(*this->typefaceProxy(), this->getRec(), glyphID, path);
return true;
return false;
}
void SkScalerContextProxy::generateFontMetrics(SkPaint::FontMetrics* metrics) {