| Index: src/codec/SkCodec.cpp
|
| diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
|
| index 5604af8d3dce27067c0439c211872f66f6e2e832..7bc9146041e7f62b590f82ca44fdf2e3ff19f22e 100644
|
| --- a/src/codec/SkCodec.cpp
|
| +++ b/src/codec/SkCodec.cpp
|
| @@ -32,8 +32,10 @@ SkCodec* SkCodec::NewFromStream(SkStream* stream) {
|
| if (!stream) {
|
| return NULL;
|
| }
|
| +
|
| + SkAutoTDelete<SkStream> streamDeleter(stream);
|
|
|
| - SkCodec* codec = NULL;
|
| + SkAutoTDelete<SkCodec> codec(NULL);
|
| for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) {
|
| DecoderProc proc = gDecoderProcs[i];
|
| const bool correctFormat = proc.IsFormat(stream);
|
| @@ -41,7 +43,7 @@ SkCodec* SkCodec::NewFromStream(SkStream* stream) {
|
| return NULL;
|
| }
|
| if (correctFormat) {
|
| - codec = proc.NewFromStream(stream);
|
| + codec.reset(proc.NewFromStream(streamDeleter.detach()));
|
| break;
|
| }
|
| }
|
| @@ -50,12 +52,11 @@ SkCodec* SkCodec::NewFromStream(SkStream* stream) {
|
| // This is about 4x smaller than a test image that takes a few minutes for
|
| // dm to decode and draw.
|
| const int32_t maxSize = 1 << 27;
|
| - if (codec != NULL &&
|
| - codec->getInfo().width() * codec->getInfo().height() > maxSize) {
|
| + if (codec && codec->getInfo().width() * codec->getInfo().height() > maxSize) {
|
| SkCodecPrintf("Error: Image size too large, cannot decode.\n");
|
| return NULL;
|
| } else {
|
| - return codec;
|
| + return codec.detach();
|
| }
|
| }
|
|
|
|
|