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

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

Issue 195223003: Fixing SkPicture serialization (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 9 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
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"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 uint32_t SkValidatingReadBuffer::getArrayCount() { 207 uint32_t SkValidatingReadBuffer::getArrayCount() {
208 const size_t inc = sizeof(uint32_t); 208 const size_t inc = sizeof(uint32_t);
209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ; 209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ;
210 return fError ? 0 : *(uint32_t*)fReader.peek(); 210 return fError ? 0 : *(uint32_t*)fReader.peek();
211 } 211 }
212 212
213 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) { 213 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) {
214 const int width = this->readInt(); 214 const int width = this->readInt();
215 const int height = this->readInt(); 215 const int height = this->readInt();
216 const bool useBitmapHeap = this->readBool();
216 const size_t length = this->readUInt(); 217 const size_t length = this->readUInt();
217 // A size of zero means the SkBitmap was simply flattened. 218 // A size of zero means the SkBitmap was simply flattened.
218 this->validate(length == 0); 219 this->validate(!useBitmapHeap && (0 == length));
219 if (fError) { 220 if (fError) {
Stephen White 2014/03/11 18:14:43 Nit: could this just be if (!this->validate(...)
sugoi1 2014/03/11 18:54:04 Done.
220 return; 221 return;
221 } 222 }
222 bitmap->unflatten(*this); 223 bitmap->unflatten(*this);
223 this->validate((bitmap->width() == width) && (bitmap->height() == height)); 224 this->validate((bitmap->width() == width) && (bitmap->height() == height));
224 } 225 }
225 226
226 SkTypeface* SkValidatingReadBuffer::readTypeface() { 227 SkTypeface* SkValidatingReadBuffer::readTypeface() {
227 // TODO: Implement this (securely) when needed 228 // TODO: Implement this (securely) when needed
228 return NULL; 229 return NULL;
229 } 230 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 delete obj; 267 delete obj;
267 obj = NULL; 268 obj = NULL;
268 } 269 }
269 } else { 270 } else {
270 // we must skip the remaining data 271 // we must skip the remaining data
271 this->skip(sizeRecorded); 272 this->skip(sizeRecorded);
272 SkASSERT(false); 273 SkASSERT(false);
273 } 274 }
274 return obj; 275 return obj;
275 } 276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698