Index: src/core/SkImageCacherator.cpp |
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp |
index bdcd64f56ddedd896ea6d3f5a66274d6f2468b0f..b138853e6136eb70bb8eb65c99a9a7739e167cc9 100644 |
--- a/src/core/SkImageCacherator.cpp |
+++ b/src/core/SkImageCacherator.cpp |
@@ -27,6 +27,10 @@ SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen, |
if (!gen) { |
return nullptr; |
} |
+ |
+ // We are required to take ownership of gen, regardless of if we return a cacherator or not |
+ SkAutoTDelete<SkImageGenerator> genHolder(gen); |
+ |
const SkImageInfo& info = gen->getInfo(); |
if (info.isEmpty()) { |
return nullptr; |
@@ -46,6 +50,10 @@ SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen, |
subset = &bounds; |
} |
+ // Now that we know we can hand-off the generator (to be owned by the cacherator) we can |
+ // release our holder. (we DONT want to delete it here anymore) |
tomhudson
2015/09/14 16:58:16
Nit: two words "any more" unless you're Edgar Alle
|
+ genHolder.detach(); |
+ |
return new SkImageCacherator(gen, gen->getInfo().makeWH(subset->width(), subset->height()), |
SkIPoint::Make(subset->x(), subset->y()), uniqueID); |
} |