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
#include "SkGifCodec.h"
#include "SkStream.h"
#include "SkSwizzler.h"
+#include "SkUtils.h"
#include <algorithm>
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) {