Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: src/core/SkBitmap.cpp

Issue 1307023004: change colortable to use factory for reinflating, check for empty (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: doh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 7cc7344d2f94432e03465cce78582aceed129e45..8d6063a62c0c12a9dcfbe2c1e36c48d03acbc1f2 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -1145,11 +1145,27 @@ 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
+ if (ctable->count() != 0) {
+ buffer->validate(false);
+ return false;
+ }
+ } else {
+ // require a non-empty ctable
+ if (ctable->count() == 0) {
+ buffer->validate(false);
+ return false;
+ }
+ unsigned char maxIndex = ctable->count() - 1;
+ for (uint64_t i = 0; i < ramSize; ++i) {
+ dst[i] = SkTMin(dst[i], maxIndex);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698