From 78a9aed075ecb342545d913bc92ef9abc6431b49 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Wed, 2 May 2018 13:53:32 +0000 Subject: [PATCH] Revert "fonts: Dont memcpy with nullptr in SkRemoteGlyphCache" This reverts commit 7e7369f7131d0b00f87cfb94e0fcbf91b02b4ee6. Reason for revert: 3 of 5 Original change's description: > fonts: Dont memcpy with nullptr in SkRemoteGlyphCache > > The behaviour is undefined and causes ASAN bots to complain. > > Bug: skia:7515 > Change-Id: I454714ab9047a6fced5ab7bfdbc12214d728eadf > Reviewed-on: https://skia-review.googlesource.com/125029 > Reviewed-by: Brian Osman > Commit-Queue: Khusal Sagar TBR=herb@google.com,brianosman@google.com,khushalsagar@chromium.org Change-Id: I6548019d7bf34b38f964234034e58af09d0b8508 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:7515 Reviewed-on: https://skia-review.googlesource.com/125262 Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- src/core/SkRemoteGlyphCache.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp index 06db562a9f..e45421aa05 100644 --- a/src/core/SkRemoteGlyphCache.cpp +++ b/src/core/SkRemoteGlyphCache.cpp @@ -549,8 +549,8 @@ void SkStrikeServer::SkGlyphCacheState::writePendingGlyphs(Serializer* serialize class SkStrikeClient::DiscardableStrikePinner : public SkStrikePinner { public: - DiscardableStrikePinner( - SkDiscardableHandleId discardableHandleId, sk_sp manager) + DiscardableStrikePinner(SkDiscardableHandleId discardableHandleId, + sk_sp manager) : fDiscardableHandleId(discardableHandleId), fManager(std::move(manager)) {} ~DiscardableStrikePinner() override = default; @@ -635,17 +635,17 @@ bool SkStrikeClient::readStrikeData(const volatile void* memory, size_t memorySi SkGlyph glyph; if (!deserializer.read(&glyph)) READ_FAILURE - SkGlyph* allocatedGlyph = strike->getRawGlyphByID(glyph.getPackedID()); - *allocatedGlyph = glyph; - ArraySlice image; auto imageSize = glyph.computeImageSize(); if (imageSize != 0) { image = deserializer.readArray(imageSize); if (!image.data()) READ_FAILURE - allocatedGlyph->allocImage(strike->getAlloc()); - memcpy(allocatedGlyph->fImage, image.data(), image.size()); } + + SkGlyph* allocatedGlyph = strike->getRawGlyphByID(glyph.getPackedID()); + *allocatedGlyph = glyph; + allocatedGlyph->allocImage(strike->getAlloc()); + memcpy(allocatedGlyph->fImage, image.data(), image.size()); } }