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

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

Issue 695633003: Objects should be unrefed instead of deleted (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use after free issue fixed Created 6 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
« 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 SkFlattenable* obj = NULL; 243 SkFlattenable* obj = NULL;
244 uint32_t sizeRecorded = this->readUInt(); 244 uint32_t sizeRecorded = this->readUInt();
245 if (factory) { 245 if (factory) {
246 size_t offset = fReader.offset(); 246 size_t offset = fReader.offset();
247 obj = (*factory)(*this); 247 obj = (*factory)(*this);
248 // check that we read the amount we expected 248 // check that we read the amount we expected
249 size_t sizeRead = fReader.offset() - offset; 249 size_t sizeRead = fReader.offset() - offset;
250 this->validate(sizeRecorded == sizeRead); 250 this->validate(sizeRecorded == sizeRead);
251 if (fError) { 251 if (fError) {
252 // we could try to fix up the offset... 252 // we could try to fix up the offset...
253 delete obj; 253 SkSafeUnref(obj);
254 obj = NULL; 254 obj = NULL;
255 } 255 }
256 } else { 256 } else {
257 // we must skip the remaining data 257 // we must skip the remaining data
258 this->skip(sizeRecorded); 258 this->skip(sizeRecorded);
259 SkASSERT(false); 259 SkASSERT(false);
260 } 260 }
261 return obj; 261 return obj;
262 } 262 }
263 263
264 void SkValidatingReadBuffer::skipFlattenable() { 264 void SkValidatingReadBuffer::skipFlattenable() {
265 SkString name; 265 SkString name;
266 this->readString(&name); 266 this->readString(&name);
267 if (fError) { 267 if (fError) {
268 return; 268 return;
269 } 269 }
270 uint32_t sizeRecorded = this->readUInt(); 270 uint32_t sizeRecorded = this->readUInt();
271 this->skip(sizeRecorded); 271 this->skip(sizeRecorded);
272 } 272 }
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