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

Side by Side Diff: src/utils/SkFrontBufferedStream.cpp

Issue 665303002: Check SkStream::isAtEnd before attempting to read. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | 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 "SkFrontBufferedStream.h" 8 #include "SkFrontBufferedStream.h"
9 #include "SkStream.h" 9 #include "SkStream.h"
10 #include "SkTemplates.h" 10 #include "SkTemplates.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // and the destination buffer. 168 // and the destination buffer.
169 size -= bytesCopied; 169 size -= bytesCopied;
170 SkASSERT(size + (fOffset - start) == totalSize); 170 SkASSERT(size + (fOffset - start) == totalSize);
171 if (dst != NULL) { 171 if (dst != NULL) {
172 dst += bytesCopied; 172 dst += bytesCopied;
173 } 173 }
174 } 174 }
175 175
176 // Buffer any more data that should be buffered, and copy it to the 176 // Buffer any more data that should be buffered, and copy it to the
177 // destination. 177 // destination.
178 if (size > 0 && fBufferedSoFar < fBufferSize) { 178 if (size > 0 && fBufferedSoFar < fBufferSize && !fStream->isAtEnd()) {
179 const size_t buffered = this->bufferAndWriteTo(dst, size); 179 const size_t buffered = this->bufferAndWriteTo(dst, size);
180 180
181 // Update the remaining number of bytes needed to read 181 // Update the remaining number of bytes needed to read
182 // and the destination buffer. 182 // and the destination buffer.
183 size -= buffered; 183 size -= buffered;
184 SkASSERT(size + (fOffset - start) == totalSize); 184 SkASSERT(size + (fOffset - start) == totalSize);
185 if (dst != NULL) { 185 if (dst != NULL) {
186 dst += buffered; 186 dst += buffered;
187 } 187 }
188 } 188 }
189 189
190 if (size > 0 && !fStream->isAtEnd()) { 190 if (size > 0 && !fStream->isAtEnd()) {
191 SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre am(dst, size); 191 SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre am(dst, size);
192 SkDEBUGCODE(size -= bytesReadDirectly;) 192 SkDEBUGCODE(size -= bytesReadDirectly;)
193 SkASSERT(size + (fOffset - start) == totalSize); 193 SkASSERT(size + (fOffset - start) == totalSize);
194 } 194 }
195 195
196 return fOffset - start; 196 return fOffset - start;
197 } 197 }
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