| 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" |
| 11 #include "SkStream.h" | 11 #include "SkStream.h" |
| 12 #include "SkTypeface.h" | 12 #include "SkTypeface.h" |
| 13 | 13 |
| 14 SkValidatingReadBuffer::SkValidatingReadBuffer(const void* data, size_t size) { | 14 SkValidatingReadBuffer::SkValidatingReadBuffer(const void* data, size_t size) : |
| 15 fError(false) { |
| 15 this->setMemory(data, size); | 16 this->setMemory(data, size); |
| 16 fError = false; | |
| 17 | |
| 18 this->setFlags(SkFlattenableReadBuffer::kValidation_Flag); | 17 this->setFlags(SkFlattenableReadBuffer::kValidation_Flag); |
| 19 } | 18 } |
| 20 | 19 |
| 21 SkValidatingReadBuffer::~SkValidatingReadBuffer() { | 20 SkValidatingReadBuffer::~SkValidatingReadBuffer() { |
| 22 } | 21 } |
| 23 | 22 |
| 24 void SkValidatingReadBuffer::setMemory(const void* data, size_t size) { | 23 void SkValidatingReadBuffer::setMemory(const void* data, size_t size) { |
| 25 fError = fError || !IsPtrAlign4(data) || (SkAlign4(size) != size); | 24 fError = fError || !IsPtrAlign4(data) || (SkAlign4(size) != size); |
| 26 if (!fError) { | 25 if (!fError) { |
| 27 fReader.setMemory(data, size); | 26 fReader.setMemory(data, size); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 delete obj; | 254 delete obj; |
| 256 obj = NULL; | 255 obj = NULL; |
| 257 } | 256 } |
| 258 } else { | 257 } else { |
| 259 // we must skip the remaining data | 258 // we must skip the remaining data |
| 260 this->skip(sizeRecorded); | 259 this->skip(sizeRecorded); |
| 261 SkASSERT(false); | 260 SkASSERT(false); |
| 262 } | 261 } |
| 263 return obj; | 262 return obj; |
| 264 } | 263 } |
| OLD | NEW |