| Index: src/core/SkValidatingReadBuffer.cpp
|
| diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp
|
| index 52006f23ad066391ee9731f942d737b54170c8b6..2de26666036a6d9752d0360ea47b6a9fab6663b8 100644
|
| --- a/src/core/SkValidatingReadBuffer.cpp
|
| +++ b/src/core/SkValidatingReadBuffer.cpp
|
| @@ -232,28 +232,25 @@ SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type)
|
| return nullptr;
|
| }
|
|
|
| - SkFlattenable::Factory factory = SkFlattenable::NameToFactory(cname);
|
| - if (nullptr == factory) {
|
| - return nullptr; // writer failed to give us the flattenable
|
| + // Get the factory for this flattenable.
|
| + SkFlattenable::Factory factory = this->getCustomFactory(name);
|
| + if (!factory) {
|
| + factory = SkFlattenable::NameToFactory(cname);
|
| + if (!factory) {
|
| + return nullptr; // writer failed to give us the flattenable
|
| + }
|
| }
|
|
|
| - // if we get here, factory may still be null, but if that is the case, the
|
| - // failure was ours, not the writer.
|
| + // If we get here, the factory is non-null.
|
| sk_sp<SkFlattenable> obj;
|
| uint32_t sizeRecorded = this->readUInt();
|
| - if (factory) {
|
| - size_t offset = fReader.offset();
|
| - obj = (*factory)(*this);
|
| - // check that we read the amount we expected
|
| - size_t sizeRead = fReader.offset() - offset;
|
| - this->validate(sizeRecorded == sizeRead);
|
| - if (fError) {
|
| - obj = nullptr;
|
| - }
|
| - } else {
|
| - // we must skip the remaining data
|
| - this->skip(sizeRecorded);
|
| - SkASSERT(false);
|
| + size_t offset = fReader.offset();
|
| + obj = (*factory)(*this);
|
| + // check that we read the amount we expected
|
| + size_t sizeRead = fReader.offset() - offset;
|
| + this->validate(sizeRecorded == sizeRead);
|
| + if (fError) {
|
| + obj = nullptr;
|
| }
|
| return obj.release();
|
| }
|
|
|