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

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

Issue 44573002: Enabling validation code in serialization and adding serialization to fuzzer (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixed SkValidatingReadBuffer's constructor Created 7 years, 1 month 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
« no previous file with comments | « src/core/SkFlattenableSerialization.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « src/core/SkFlattenableSerialization.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698