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

Unified Diff: src/core/SkStream.cpp

Issue 187683003: Prevent SkBlockMemoryStream::skip from writing to low memory. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkStream.cpp
===================================================================
--- src/core/SkStream.cpp (revision 13670)
+++ src/core/SkStream.cpp (working copy)
@@ -694,10 +694,10 @@
size_t bytesLeftToRead = count;
while (fCurrent != NULL) {
size_t bytesLeftInCurrent = fCurrent->written() - fCurrentOffset;
- size_t bytesFromCurrent = bytesLeftToRead <= bytesLeftInCurrent
- ? bytesLeftToRead : bytesLeftInCurrent;
+ size_t bytesFromCurrent = SkTMin(bytesLeftToRead, bytesLeftInCurrent);
if (buffer) {
memcpy(buffer, fCurrent->start() + fCurrentOffset, bytesFromCurrent);
+ buffer = SkTAddOffset<void>(buffer, bytesFromCurrent);
}
if (bytesLeftToRead <= bytesFromCurrent) {
fCurrentOffset += bytesFromCurrent;
@@ -705,7 +705,6 @@
return count;
}
bytesLeftToRead -= bytesFromCurrent;
- buffer = SkTAddOffset<void>(buffer, bytesFromCurrent);
fCurrent = fCurrent->fNext;
fCurrentOffset = 0;
}
« 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