diff --git a/third_party/skia/src/core/SkTypeface_remote.cpp b/third_party/skia/src/core/SkTypeface_remote.cpp index fb3fb60eeb..8e8d328806 100644 --- a/third_party/skia/src/core/SkTypeface_remote.cpp +++ b/third_party/skia/src/core/SkTypeface_remote.cpp @@ -44,12 +44,21 @@ SkScalerContext::GlyphMetrics SkScalerContextProxy::generateMetrics(const SkGlyp return {glyph.maskFormat()}; } -void SkScalerContextProxy::generateImage(const SkGlyph& glyph, void*) { +void SkScalerContextProxy::generateImage(const SkGlyph& glyph, void* imageBuffer) { TRACE_EVENT1("skia", "generateImage", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); if (this->getProxyTypeface()->isLogging()) { SkDebugf("GlyphCacheMiss generateImage: %s\n", this->getRec().dump().c_str()); } + // The caller (SkGlyph::setImage) has freshly allocated |imageBuffer| via + // SkArenaAlloc::makeBytesAlignedTo (sk_malloc_throw under the hood) and + // expects this method to fill it. Since we have no glyph data on a cache + // miss, zero the buffer so that uninitialized GPU-process heap is not + // uploaded to the atlas texture and disclosed to a compromised renderer. + if (imageBuffer != nullptr) { + sk_bzero(imageBuffer, glyph.imageSize()); + } + // There is no desperation search here, because if there was an image to be found it was // copied over with the metrics search. fDiscardableManager->notifyCacheMiss(