OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
10 #include "SkValidatingReadBuffer.h" | 10 #include "SkValidatingReadBuffer.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 uint32_t SkValidatingReadBuffer::getArrayCount() { | 207 uint32_t SkValidatingReadBuffer::getArrayCount() { |
208 const size_t inc = sizeof(uint32_t); | 208 const size_t inc = sizeof(uint32_t); |
209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc)
; | 209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc)
; |
210 return fError ? 0 : *(uint32_t*)fReader.peek(); | 210 return fError ? 0 : *(uint32_t*)fReader.peek(); |
211 } | 211 } |
212 | 212 |
213 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) { | 213 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) { |
214 const int width = this->readInt(); | 214 const int width = this->readInt(); |
215 const int height = this->readInt(); | 215 const int height = this->readInt(); |
| 216 const bool useBitmapHeap = this->readBool(); |
216 const size_t length = this->readUInt(); | 217 const size_t length = this->readUInt(); |
217 // A size of zero means the SkBitmap was simply flattened. | 218 // A size of zero means the SkBitmap was simply flattened. |
218 this->validate(length == 0); | 219 if (!this->validate(!useBitmapHeap && (0 == length))) { |
219 if (fError) { | |
220 return; | 220 return; |
221 } | 221 } |
222 bitmap->unflatten(*this); | 222 bitmap->unflatten(*this); |
223 this->validate((bitmap->width() == width) && (bitmap->height() == height)); | 223 this->validate((bitmap->width() == width) && (bitmap->height() == height)); |
224 } | 224 } |
225 | 225 |
226 SkTypeface* SkValidatingReadBuffer::readTypeface() { | 226 SkTypeface* SkValidatingReadBuffer::readTypeface() { |
227 // TODO: Implement this (securely) when needed | 227 // TODO: Implement this (securely) when needed |
228 return NULL; | 228 return NULL; |
229 } | 229 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 delete obj; | 266 delete obj; |
267 obj = NULL; | 267 obj = NULL; |
268 } | 268 } |
269 } else { | 269 } else { |
270 // we must skip the remaining data | 270 // we must skip the remaining data |
271 this->skip(sizeRecorded); | 271 this->skip(sizeRecorded); |
272 SkASSERT(false); | 272 SkASSERT(false); |
273 } | 273 } |
274 return obj; | 274 return obj; |
275 } | 275 } |
OLD | NEW |