Chromium Code Reviews| Index: src/core/SkBitmap.cpp |
| diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp |
| index 7cc7344d2f94432e03465cce78582aceed129e45..4121f97993e11b910b371162e9c1d32c897a1f89 100644 |
| --- a/src/core/SkBitmap.cpp |
| +++ b/src/core/SkBitmap.cpp |
| @@ -1145,9 +1145,16 @@ bool SkBitmap::ReadRawPixels(SkReadBuffer* buffer, SkBitmap* bitmap) { |
| SkAutoTUnref<SkColorTable> ctable; |
| if (buffer->readBool()) { |
| - ctable.reset(new SkColorTable(*buffer)); |
| + ctable.reset(SkColorTable::Create(*buffer)); |
| + if (!ctable) { |
| + return false; |
| + } |
| + // only permit an empty table if we have no pixels |
|
robertphillips
2015/08/28 15:58:53
seems some guard is missing here
reed1
2015/08/28 16:01:08
Done.
|
| + if (ctable->count() == 0 && info.width() > 0 && info.height() > 0) { |
| + return false; |
| + } |
| - unsigned char maxIndex = ctable->count() ? ctable->count()-1 : 0; |
| + unsigned char maxIndex = ctable->count() - 1; |
| for (uint64_t i = 0; i < ramSize; ++i) { |
| dst[i] = SkTMin(dst[i], maxIndex); |
| } |