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

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

Issue 88643004: Fixed bad memory access (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | « no previous file | 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"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return readArray(points, size, sizeof(SkPoint)); 196 return readArray(points, size, sizeof(SkPoint));
197 } 197 }
198 198
199 bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) { 199 bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) {
200 return readArray(values, size, sizeof(SkScalar)); 200 return readArray(values, size, sizeof(SkScalar));
201 } 201 }
202 202
203 uint32_t SkValidatingReadBuffer::getArrayCount() { 203 uint32_t SkValidatingReadBuffer::getArrayCount() {
204 const size_t inc = sizeof(uint32_t); 204 const size_t inc = sizeof(uint32_t);
205 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ; 205 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ;
206 return *(uint32_t*)fReader.peek(); 206 return fError ? 0 : *(uint32_t*)fReader.peek();
207 } 207 }
208 208
209 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) { 209 void SkValidatingReadBuffer::readBitmap(SkBitmap* bitmap) {
210 const int width = this->readInt(); 210 const int width = this->readInt();
211 const int height = this->readInt(); 211 const int height = this->readInt();
212 const size_t length = this->readUInt(); 212 const size_t length = this->readUInt();
213 // A size of zero means the SkBitmap was simply flattened. 213 // A size of zero means the SkBitmap was simply flattened.
214 this->validate(length == 0); 214 this->validate(length == 0);
215 if (fError) { 215 if (fError) {
216 return; 216 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 delete obj; 258 delete obj;
259 obj = NULL; 259 obj = NULL;
260 } 260 }
261 } else { 261 } else {
262 // we must skip the remaining data 262 // we must skip the remaining data
263 this->skip(sizeRecorded); 263 this->skip(sizeRecorded);
264 SkASSERT(false); 264 SkASSERT(false);
265 } 265 }
266 return obj; 266 return obj;
267 } 267 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698