diff options
author | scroggo <scroggo@chromium.org> | 2016-10-25 12:48:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-25 12:48:25 -0700 |
commit | 0057ac11fccc82bc5b0c1bb0aefe838cc04efd13 (patch) | |
tree | d75089631c34819ae1f6b94ff312f77fa4d43dc6 /src | |
parent | e9db0b7f0e9185c04e54b53f65a882958be3394c (diff) |
Always use a color table with 256 colors
Speculative fix for skbug.com/5883
We are hitting an assert (which I have not been able to repro - still
need to get the skp that triggers it) because we are trying to read
beyond the end of the color table. We use 8-bit indices, so 256 should
be enough to prevent going beyond the end. There is only one case when
we use a smaller color table - when it is a dummy. Make the dummy full
size.
NOTREECHECKS=true
BUG=skia:5883
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2452673002
Review-Url: https://codereview.chromium.org/2452673002
Diffstat (limited to 'src')
-rw-r--r-- | src/codec/SkGifCodec.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp index 263004b6cd..e55f6f3a6e 100644 --- a/src/codec/SkGifCodec.cpp +++ b/src/codec/SkGifCodec.cpp @@ -37,6 +37,7 @@ #include "SkGifCodec.h" #include "SkStream.h" #include "SkSwizzler.h" +#include "SkUtils.h" #include <algorithm> @@ -143,9 +144,10 @@ void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, size_t frameIn fCurrColorTable = fReader->getColorTable(dstInfo.colorType(), frameIndex); fCurrColorTableIsReal = fCurrColorTable; if (!fCurrColorTable) { - // This is possible for an empty frame. Create a dummy with one value (transparent). - SkPMColor color = SK_ColorTRANSPARENT; - fCurrColorTable.reset(new SkColorTable(&color, 1)); + // This is possible for an empty frame. Create a dummy with all transparent. + SkPMColor colors[MAX_COLORS]; + sk_memset32(colors, SK_ColorTRANSPARENT, MAX_COLORS); + fCurrColorTable.reset(new SkColorTable(colors, 256)); } if (inputColorCount) { |