Chromium Code Reviews| Index: src/core/SkValidatingReadBuffer.cpp |
| diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp |
| index 52006f23ad066391ee9731f942d737b54170c8b6..8807cc07f64e8b6dbc5af855e8cd72b7a6729089 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 = getCustomFactory(name); |
|
mtklein
2016/04/19 18:14:55
this->
msarett
2016/04/19 18:55:51
Done.
|
| + 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(); |
| } |