Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: tools/SkBitmapRegionDecoderInterface.cpp

Issue 1396113003: Fix codec memory leaks in nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/subset/SubsetTranslateBench.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/SkBitmapRegionDecoderInterface.cpp
diff --git a/tools/SkBitmapRegionDecoderInterface.cpp b/tools/SkBitmapRegionDecoderInterface.cpp
index 47de31f4ec01c045ab8dad11059b0f292de037e7..eea2441dd239c75fca378f529f6e92179c7708da 100644
--- a/tools/SkBitmapRegionDecoderInterface.cpp
+++ b/tools/SkBitmapRegionDecoderInterface.cpp
@@ -13,6 +13,7 @@
SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(
SkStreamRewindable* stream, Strategy strategy) {
+ SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
switch (strategy) {
case kOriginal_Strategy: {
SkImageDecoder* decoder = SkImageDecoder::Factory(stream);
@@ -21,7 +22,7 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
SkDebugf("Error: Could not create image decoder.\n");
return nullptr;
}
- if (!decoder->buildTileIndex(stream, &width, &height)) {
+ if (!decoder->buildTileIndex(streamDeleter.detach(), &width, &height)) {
SkDebugf("Error: Could not build tile index.\n");
delete decoder;
return nullptr;
@@ -29,7 +30,7 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
return new SkBitmapRegionSampler(decoder, width, height);
}
case kCanvas_Strategy: {
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.detach()));
if (nullptr == codec) {
SkDebugf("Error: Failed to create decoder.\n");
return nullptr;
« no previous file with comments | « bench/subset/SubsetTranslateBench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698