Index: tools/SkBitmapRegionDecoderInterface.cpp |
diff --git a/tools/SkBitmapRegionDecoderInterface.cpp b/tools/SkBitmapRegionDecoderInterface.cpp |
index 5c769d676e4377da9ee1f34e1aeb06d76c48c9f0..47de31f4ec01c045ab8dad11059b0f292de037e7 100644 |
--- a/tools/SkBitmapRegionDecoderInterface.cpp |
+++ b/tools/SkBitmapRegionDecoderInterface.cpp |
@@ -29,12 +29,12 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi |
return new SkBitmapRegionSampler(decoder, width, height); |
} |
case kCanvas_Strategy: { |
- SkCodec* decoder = SkCodec::NewFromStream(stream); |
- if (nullptr == decoder) { |
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream)); |
+ if (nullptr == codec) { |
SkDebugf("Error: Failed to create decoder.\n"); |
return nullptr; |
} |
- switch (decoder->getScanlineOrder()) { |
+ switch (codec->getScanlineOrder()) { |
case SkCodec::kTopDown_SkScanlineOrder: |
case SkCodec::kNone_SkScanlineOrder: |
break; |
@@ -42,7 +42,7 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi |
SkDebugf("Error: Scanline ordering not supported.\n"); |
return nullptr; |
} |
- return new SkBitmapRegionCanvas(decoder); |
+ return new SkBitmapRegionCanvas(codec.detach()); |
} |
default: |
SkASSERT(false); |