aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2015-10-09 12:15:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-09 12:15:57 -0700
commite361781bf7ce8acd4af00c426b34596804d45d77 (patch)
treefc86055989bedc6145b070007007051bff90737a /tools
parente6dd004c1b8a81dc37a370570877b8b7d6dbe308 (diff)
Fix codec memory leaks in nanobench
SubsetTranslateBench.cpp: Unref the color table, so it gets deleted. SkBitmapRegionDecoderInterface.cpp: Delete the stream if it is not used. BUG=skia:3418 Review URL: https://codereview.chromium.org/1396113003
Diffstat (limited to 'tools')
-rw-r--r--tools/SkBitmapRegionDecoderInterface.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/SkBitmapRegionDecoderInterface.cpp b/tools/SkBitmapRegionDecoderInterface.cpp
index 47de31f4ec..eea2441dd2 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;