aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkBmpCodec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/codec/SkBmpCodec.cpp')
-rw-r--r--src/codec/SkBmpCodec.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp
index 3158e992d2..0525d9530c 100644
--- a/src/codec/SkBmpCodec.cpp
+++ b/src/codec/SkBmpCodec.cpp
@@ -481,8 +481,13 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) {
// Set the image info and create a codec.
const SkEncodedInfo info = SkEncodedInfo::Make(color, alpha, bitsPerComponent);
- *codecOut = new SkBmpStandardCodec(width, height, info, stream, bitsPerPixel,
- numColors, bytesPerColor, offset - bytesRead, rowOrder, isOpaque, inIco);
+ std::unique_ptr<SkBmpStandardCodec> codec(new SkBmpStandardCodec(width, height,
+ info, stream, bitsPerPixel, numColors, bytesPerColor, offset - bytesRead,
+ rowOrder, isOpaque, inIco));
+ if (!codec->didCreateSrcBuffer()) {
+ return false;
+ }
+ *codecOut = codec.release();
}
return true;
}
@@ -534,8 +539,12 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) {
alpha = SkEncodedInfo::kOpaque_Alpha;
}
const SkEncodedInfo info = SkEncodedInfo::Make(color, alpha, 8);
- *codecOut = new SkBmpMaskCodec(width, height, info, stream, bitsPerPixel,
- masks.release(), rowOrder);
+ std::unique_ptr<SkBmpMaskCodec> codec(new SkBmpMaskCodec(width, height, info,
+ stream, bitsPerPixel, masks.release(), rowOrder));
+ if (!codec->didCreateSrcBuffer()) {
+ return false;
+ }
+ *codecOut = codec.release();
}
return true;
}