Index: src/lazy/SkDiscardablePixelRef.cpp |
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp |
index 160ca5b4fbacdaae84f040c5eae3084f10b36cd6..2886156102937faeb734f2891b74daaff47dba61 100644 |
--- a/src/lazy/SkDiscardablePixelRef.cpp |
+++ b/src/lazy/SkDiscardablePixelRef.cpp |
@@ -72,20 +72,19 @@ bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, |
SkBitmap* dst, |
SkDiscardableMemory::Factory* factory) { |
SkImageInfo info; |
- SkASSERT(generator != NULL); |
- if ((NULL == generator) |
- || (!generator->getInfo(&info)) |
+ SkAutoTDelete<SkImageGenerator> autoGenerator(generator); |
+ if ((NULL == autoGenerator.get()) |
+ || (!autoGenerator->getInfo(&info)) |
|| (!dst->setConfig(info, 0))) { |
- SkDELETE(generator); |
return false; |
} |
SkASSERT(dst->config() != SkBitmap::kNo_Config); |
- if (dst->empty()) { // Use a normal pixelref. |
- SkDELETE(generator); // Do not need this anymore. |
+ if (dst->empty()) { // Use a normal pixelref. |
return dst->allocPixels(NULL, NULL); |
} |
- SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef, |
- (info, generator, dst->rowBytes(), factory))); |
+ SkAutoTUnref<SkDiscardablePixelRef> ref( |
+ SkNEW_ARGS(SkDiscardablePixelRef, |
+ (info, autoGenerator.detach(), dst->rowBytes(), factory))); |
dst->setPixelRef(ref); |
return true; |
} |