aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmap.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-08-28 10:14:18 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-28 10:14:18 -0700
commitb236d1a37bd8ee936587faa0a55128a1f901cb5a (patch)
tree4d9710961c29857ad74ec6fbd0c725cb94e27e22 /src/core/SkBitmap.cpp
parent62ce0303fb3f9857ee3ab8df05934642c226b1a3 (diff)
change colortable to use factory for reinflating, check for empty
Diffstat (limited to 'src/core/SkBitmap.cpp')
-rw-r--r--src/core/SkBitmap.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 7d08184ed8..6fd97dc241 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);
+ }
}
}