OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkErrorInternals.h" | 10 #include "SkErrorInternals.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 return NULL; // writer failed to give us the flattenable | 292 return NULL; // writer failed to give us the flattenable |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 // if we get here, factory may still be null, but if that is the case, the | 296 // if we get here, factory may still be null, but if that is the case, the |
297 // failure was ours, not the writer. | 297 // failure was ours, not the writer. |
298 SkFlattenable* obj = NULL; | 298 SkFlattenable* obj = NULL; |
299 uint32_t sizeRecorded = fReader.readU32(); | 299 uint32_t sizeRecorded = fReader.readU32(); |
300 if (factory) { | 300 if (factory) { |
301 uint32_t offset = fReader.offset(); | 301 uint32_t offset = fReader.offset(); |
302 fError = false; // Reset error state before calling factory function | |
302 obj = (*factory)(*this); | 303 obj = (*factory)(*this); |
304 if (fError) { | |
scroggo
2013/08/21 23:56:00
From here, do we assume the rest of this stream is
sugoi1
2013/08/22 14:26:23
For now, since we don't what kind of error we hit,
| |
305 delete obj; | |
306 obj = NULL; | |
307 } | |
303 // check that we read the amount we expected | 308 // check that we read the amount we expected |
304 uint32_t sizeRead = fReader.offset() - offset; | 309 uint32_t sizeRead = fReader.offset() - offset; |
305 if (sizeRecorded != sizeRead) { | 310 if (sizeRecorded != sizeRead) { |
306 // we could try to fix up the offset... | 311 // we could try to fix up the offset... |
307 sk_throw(); | 312 sk_throw(); |
308 } | 313 } |
309 } else { | 314 } else { |
310 // we must skip the remaining data | 315 // we must skip the remaining data |
311 fReader.skip(sizeRecorded); | 316 fReader.skip(sizeRecorded); |
312 } | 317 } |
313 return obj; | 318 return obj; |
314 } | 319 } |
OLD | NEW |