| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return readArray(points, size, sizeof(SkPoint)); | 196 return readArray(points, size, sizeof(SkPoint)); |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) { | 199 bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) { |
| 200 return readArray(values, size, sizeof(SkScalar)); | 200 return readArray(values, size, sizeof(SkScalar)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 uint32_t SkValidatingReadBuffer::getArrayCount() { | 203 uint32_t SkValidatingReadBuffer::getArrayCount() { |
| 204 const size_t inc = sizeof(uint32_t); | 204 const size_t inc = sizeof(uint32_t); |
| 205 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc)
; | 205 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc)
; |
| 206 return *(uint32_t*)fReader.peek(); | 206 return fError ? 0 : *(uint32_t*)fReader.peek(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) { | 209 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) { |
| 210 const int width = this->readInt(); | 210 const int width = this->readInt(); |
| 211 const int height = this->readInt(); | 211 const int height = this->readInt(); |
| 212 const size_t length = this->readUInt(); | 212 const size_t length = this->readUInt(); |
| 213 // A size of zero means the SkBitmap was simply flattened. | 213 // A size of zero means the SkBitmap was simply flattened. |
| 214 this->validate(length == 0); | 214 this->validate(length == 0); |
| 215 if (fError) { | 215 if (fError) { |
| 216 return; | 216 return; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 delete obj; | 258 delete obj; |
| 259 obj = NULL; | 259 obj = NULL; |
| 260 } | 260 } |
| 261 } else { | 261 } else { |
| 262 // we must skip the remaining data | 262 // we must skip the remaining data |
| 263 this->skip(sizeRecorded); | 263 this->skip(sizeRecorded); |
| 264 SkASSERT(false); | 264 SkASSERT(false); |
| 265 } | 265 } |
| 266 return obj; | 266 return obj; |
| 267 } | 267 } |
| OLD | NEW |