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

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

Issue 106943002: Fixed a few places where uninitialized memory could have been read (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Removed bad scalar checks in SkColorMatrixFilter.cpp 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
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 11 matching lines...) Expand all
22 22
23 bool SkValidatingReadBuffer::validate(bool isValid) { 23 bool SkValidatingReadBuffer::validate(bool isValid) {
24 if (!fError && !isValid) { 24 if (!fError && !isValid) {
25 // When an error is found, send the read cursor to the end of the stream 25 // When an error is found, send the read cursor to the end of the stream
26 fReader.skip(fReader.available()); 26 fReader.skip(fReader.available());
27 fError = true; 27 fError = true;
28 } 28 }
29 return !fError; 29 return !fError;
30 } 30 }
31 31
32 bool SkValidatingReadBuffer::isValid() const {
33 return !fError;
34 }
35
32 void SkValidatingReadBuffer::setMemory(const void* data, size_t size) { 36 void SkValidatingReadBuffer::setMemory(const void* data, size_t size) {
33 this->validate(IsPtrAlign4(data) && (SkAlign4(size) == size)); 37 this->validate(IsPtrAlign4(data) && (SkAlign4(size) == size));
34 if (!fError) { 38 if (!fError) {
35 fReader.setMemory(data, size); 39 fReader.setMemory(data, size);
36 } 40 }
37 } 41 }
38 42
39 const void* SkValidatingReadBuffer::skip(size_t size) { 43 const void* SkValidatingReadBuffer::skip(size_t size) {
40 size_t inc = SkAlign4(size); 44 size_t inc = SkAlign4(size);
41 const void* addr = fReader.peek(); 45 const void* addr = fReader.peek();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 delete obj; 262 delete obj;
259 obj = NULL; 263 obj = NULL;
260 } 264 }
261 } else { 265 } else {
262 // we must skip the remaining data 266 // we must skip the remaining data
263 this->skip(sizeRecorded); 267 this->skip(sizeRecorded);
264 SkASSERT(false); 268 SkASSERT(false);
265 } 269 }
266 return obj; 270 return obj;
267 } 271 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698