Chromium Code Reviews

Unified Diff: src/core/SkValidatingReadBuffer.cpp

Issue 1855733002: change flattenable factory to return sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: src/core/SkValidatingReadBuffer.cpp
diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp
index bc5611a3e382902878ca99256f6d26ff0e80c3c2..ad4b6c409e6a0adca7c85b87c69a59089ac76779 100644
--- a/src/core/SkValidatingReadBuffer.cpp
+++ b/src/core/SkValidatingReadBuffer.cpp
@@ -243,7 +243,7 @@ SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type)
// if we get here, factory may still be null, but if that is the case, the
// failure was ours, not the writer.
- SkFlattenable* obj = nullptr;
+ sk_sp<SkFlattenable> obj;
uint32_t sizeRecorded = this->readUInt();
if (factory) {
size_t offset = fReader.offset();
@@ -252,8 +252,6 @@ SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type)
size_t sizeRead = fReader.offset() - offset;
this->validate(sizeRecorded == sizeRead);
if (fError) {
- // we could try to fix up the offset...
- SkSafeUnref(obj);
obj = nullptr;
}
} else {
@@ -261,7 +259,7 @@ SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type)
this->skip(sizeRecorded);
SkASSERT(false);
}
- return obj;
+ return obj.release();
}
void SkValidatingReadBuffer::skipFlattenable() {

Powered by Google App Engine