Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: src/core/SkOrderedReadBuffer.cpp

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 2nd proposition, with some comments adressed Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698