| Index: src/images/SkImageDecoder_libbmp.cpp
|
| diff --git a/src/images/SkImageDecoder_libbmp.cpp b/src/images/SkImageDecoder_libbmp.cpp
|
| index 179162356aec980067ee6548c228d13d967b0cc0..4a6f71c82db06a383009343825dca99838a56d5a 100644
|
| --- a/src/images/SkImageDecoder_libbmp.cpp
|
| +++ b/src/images/SkImageDecoder_libbmp.cpp
|
| @@ -9,6 +9,7 @@
|
|
|
| #include "bmpdecoderhelper.h"
|
| #include "SkColorPriv.h"
|
| +#include "SkData.h"
|
| #include "SkImageDecoder.h"
|
| #include "SkScaledBitmapSampler.h"
|
| #include "SkStream.h"
|
| @@ -96,10 +97,13 @@ SkImageDecoder::Result SkBMPImageDecoder::onDecode(SkStream* stream, SkBitmap* b
|
| // First read the entire stream, so that all of the data can be passed to
|
| // the BmpDecoderHelper.
|
|
|
| - // Allocated space used to hold the data.
|
| - SkAutoMalloc storage;
|
| + SkAutoTUnref<SkData> data(SkCopyStreamToData(stream));
|
| + if (!data) {
|
| + return kFailure;
|
| + }
|
| +
|
| // Byte length of all of the data.
|
| - const size_t length = SkCopyStreamToStorage(&storage, stream);
|
| + const size_t length = data->size();
|
| if (0 == length) {
|
| return kFailure;
|
| }
|
| @@ -111,7 +115,7 @@ SkImageDecoder::Result SkBMPImageDecoder::onDecode(SkStream* stream, SkBitmap* b
|
| {
|
| image_codec::BmpDecoderHelper helper;
|
| const int max_pixels = 16383*16383; // max width*height
|
| - if (!helper.DecodeImage((const char*)storage.get(), length,
|
| + if (!helper.DecodeImage((const char*) data->data(), length,
|
| max_pixels, &callback)) {
|
| return kFailure;
|
| }
|
| @@ -119,7 +123,7 @@ SkImageDecoder::Result SkBMPImageDecoder::onDecode(SkStream* stream, SkBitmap* b
|
|
|
| // we don't need this anymore, so free it now (before we try to allocate
|
| // the bitmap's pixels) rather than waiting for its destructor
|
| - storage.free();
|
| + data.reset(nullptr);
|
|
|
| int width = callback.width();
|
| int height = callback.height();
|
|
|