Revert "fonts: Dont memcpy with nullptr in SkRemoteGlyphCache"

This reverts commit 7e7369f713.

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 <brianosman@google.com>
> Commit-Queue: Khusal Sagar <khushalsagar@chromium.org>

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 <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2018-05-02 13:53:32 +00:00
parent 192b18a261
commit 78a9aed075

View File

@ -549,8 +549,8 @@ void SkStrikeServer::SkGlyphCacheState::writePendingGlyphs(Serializer* serialize
class SkStrikeClient::DiscardableStrikePinner : public SkStrikePinner {
public:
DiscardableStrikePinner(
SkDiscardableHandleId discardableHandleId, sk_sp<DiscardableHandleManager> manager)
DiscardableStrikePinner(SkDiscardableHandleId discardableHandleId,
sk_sp<DiscardableHandleManager> 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<SkGlyph>(&glyph)) READ_FAILURE
SkGlyph* allocatedGlyph = strike->getRawGlyphByID(glyph.getPackedID());
*allocatedGlyph = glyph;
ArraySlice<uint8_t> image;
auto imageSize = glyph.computeImageSize();
if (imageSize != 0) {
image = deserializer.readArray<uint8_t>(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());
}
}