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

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

Issue 1691383002: Make SkRWBuffer destruct safely (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | tests/DataRefTest.cpp » ('j') | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkRWBuffer.h" 8 #include "SkRWBuffer.h"
9 #include "SkStream.h" 9 #include "SkStream.h"
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 fRemaining -= this->size(); 161 fRemaining -= this->size();
162 fBlock = fBlock->fNext; 162 fBlock = fBlock->fNext;
163 } 163 }
164 return fRemaining != 0; 164 return fRemaining != 0;
165 } 165 }
166 166
167 SkRWBuffer::SkRWBuffer(size_t initialCapacity) : fHead(nullptr), fTail(nullptr), fTotalUsed(0) {} 167 SkRWBuffer::SkRWBuffer(size_t initialCapacity) : fHead(nullptr), fTail(nullptr), fTotalUsed(0) {}
168 168
169 SkRWBuffer::~SkRWBuffer() { 169 SkRWBuffer::~SkRWBuffer() {
170 this->validate(); 170 this->validate();
171 fHead->unref(); 171 if (fHead) {
172 fHead->unref();
173 }
172 } 174 }
173 175
174 void SkRWBuffer::append(const void* src, size_t length) { 176 void SkRWBuffer::append(const void* src, size_t length) {
175 this->validate(); 177 this->validate();
176 if (0 == length) { 178 if (0 == length) {
177 return; 179 return;
178 } 180 }
179 181
180 fTotalUsed += length; 182 fTotalUsed += length;
181 183
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 const SkROBuffer* fBuffer; 345 const SkROBuffer* fBuffer;
344 SkROBuffer::Iter fIter; 346 SkROBuffer::Iter fIter;
345 size_t fLocalOffset; 347 size_t fLocalOffset;
346 size_t fGlobalOffset; 348 size_t fGlobalOffset;
347 }; 349 };
348 350
349 SkStreamAsset* SkRWBuffer::newStreamSnapshot() const { 351 SkStreamAsset* SkRWBuffer::newStreamSnapshot() const {
350 SkAutoTUnref<SkROBuffer> buffer(this->newRBufferSnapshot()); 352 SkAutoTUnref<SkROBuffer> buffer(this->newRBufferSnapshot());
351 return new SkROBufferStreamAsset(buffer); 353 return new SkROBufferStreamAsset(buffer);
352 } 354 }
OLDNEW
« no previous file with comments | « no previous file | tests/DataRefTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698