diff options
author | msarett <msarett@google.com> | 2016-05-04 13:03:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-04 13:03:48 -0700 |
commit | 3e375b0a51a46814cf08ecd1a513862006a704e5 (patch) | |
tree | b3cdfbd65951301fa0ec048303497e93825b7a01 /src/codec/SkBmpStandardCodec.cpp | |
parent | 76948d4faaca9fd7730576e2f79790ca8d93c10b (diff) |
Fix ICO bug exposed by the fuzzer
BUG=skia:5248
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1949773002
Review-Url: https://codereview.chromium.org/1949773002
Diffstat (limited to 'src/codec/SkBmpStandardCodec.cpp')
-rw-r--r-- | src/codec/SkBmpStandardCodec.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp index 358da057c6..651ff83b8a 100644 --- a/src/codec/SkBmpStandardCodec.cpp +++ b/src/codec/SkBmpStandardCodec.cpp @@ -150,13 +150,18 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo, } void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) { - // In the case of paletted ico-in-bmps, we will report BGRA to the client, - // since we may be required to apply an alpha mask after the decode. But - // the swizzler needs to know the actual format of the bmp. + // In the case of bmp-in-icos, we will report BGRA to the client, + // since we may be required to apply an alpha mask after the decode. + // However, the swizzler needs to know the actual format of the bmp. SkEncodedInfo swizzlerInfo = this->getEncodedInfo(); - if (fInIco && this->bitsPerPixel() <= 8) { - swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kPalette_Color, swizzlerInfo.alpha(), - this->bitsPerPixel()); + if (fInIco) { + if (this->bitsPerPixel() <= 8) { + swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kPalette_Color, + swizzlerInfo.alpha(), this->bitsPerPixel()); + } else if (this->bitsPerPixel() == 24) { + swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kBGR_Color, + SkEncodedInfo::kOpaque_Alpha, 8); + } } // Get a pointer to the color table if it exists |