Index: src/core/SkBitmap.cpp |
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp |
index 7cc7344d2f94432e03465cce78582aceed129e45..a02fd5e0a0efa62bf5b71cada0ecae665146e445 100644 |
--- a/src/core/SkBitmap.cpp |
+++ b/src/core/SkBitmap.cpp |
@@ -1145,11 +1145,25 @@ 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; |
+ } |
- unsigned char maxIndex = ctable->count() ? ctable->count()-1 : 0; |
- for (uint64_t i = 0; i < ramSize; ++i) { |
- dst[i] = SkTMin(dst[i], maxIndex); |
+ if (info.isEmpty()) { |
+ // require an empty ctable |
robertphillips
2015/08/28 16:31:43
'!=' instead of '!'...'==' ?
reed1
2015/08/28 17:00:36
Done.
|
+ if (!buffer->validate(ctable->count() == 0)) { |
+ return false; |
+ } |
+ } else { |
+ // require a non-empty ctable |
robertphillips
2015/08/28 16:31:43
'<=' instead of '!'...'>' ?
reed1
2015/08/28 17:00:36
Done.
|
+ if (!buffer->validate(ctable->count() > 0)) { |
+ return false; |
+ } |
+ unsigned char maxIndex = ctable->count() - 1; |
+ for (uint64_t i = 0; i < ramSize; ++i) { |
+ dst[i] = SkTMin(dst[i], maxIndex); |
+ } |
} |
} |