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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 SkFlattenable* obj = NULL; | 243 SkFlattenable* obj = NULL; |
244 uint32_t sizeRecorded = this->readUInt(); | 244 uint32_t sizeRecorded = this->readUInt(); |
245 if (factory) { | 245 if (factory) { |
246 size_t offset = fReader.offset(); | 246 size_t offset = fReader.offset(); |
247 obj = (*factory)(*this); | 247 obj = (*factory)(*this); |
248 // check that we read the amount we expected | 248 // check that we read the amount we expected |
249 size_t sizeRead = fReader.offset() - offset; | 249 size_t sizeRead = fReader.offset() - offset; |
250 this->validate(sizeRecorded == sizeRead); | 250 this->validate(sizeRecorded == sizeRead); |
251 if (fError) { | 251 if (fError) { |
252 // we could try to fix up the offset... | 252 // we could try to fix up the offset... |
253 delete obj; | 253 SkSafeUnref(obj); |
254 obj = NULL; | 254 obj = NULL; |
255 } | 255 } |
256 } else { | 256 } else { |
257 // we must skip the remaining data | 257 // we must skip the remaining data |
258 this->skip(sizeRecorded); | 258 this->skip(sizeRecorded); |
259 SkASSERT(false); | 259 SkASSERT(false); |
260 } | 260 } |
261 return obj; | 261 return obj; |
262 } | 262 } |
263 | 263 |
264 void SkValidatingReadBuffer::skipFlattenable() { | 264 void SkValidatingReadBuffer::skipFlattenable() { |
265 SkString name; | 265 SkString name; |
266 this->readString(&name); | 266 this->readString(&name); |
267 if (fError) { | 267 if (fError) { |
268 return; | 268 return; |
269 } | 269 } |
270 uint32_t sizeRecorded = this->readUInt(); | 270 uint32_t sizeRecorded = this->readUInt(); |
271 this->skip(sizeRecorded); | 271 this->skip(sizeRecorded); |
272 } | 272 } |
OLD | NEW |