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

Unified Diff: Source/platform/image-decoders/FastSharedBufferReader.cpp

Issue 1011113003: Fix potential bug in FastSharedBufferReader::getConsecutiveData (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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
Index: Source/platform/image-decoders/FastSharedBufferReader.cpp
diff --git a/Source/platform/image-decoders/FastSharedBufferReader.cpp b/Source/platform/image-decoders/FastSharedBufferReader.cpp
index 4475960fdcb4a12dab70112a482d779630b558e4..e02a70551c706556f5f4b1787cc1f8eae29248bc 100644
--- a/Source/platform/image-decoders/FastSharedBufferReader.cpp
+++ b/Source/platform/image-decoders/FastSharedBufferReader.cpp
@@ -56,17 +56,25 @@ const char* FastSharedBufferReader::getConsecutiveData(size_t dataPosition, size
if (length <= m_segmentLength)
return m_segment;
- for (char* tempBuffer = buffer; length;) {
+ char* dest = buffer;
Peter Kasting 2015/03/20 20:29:33 Nit: Convert the while to a for so you can move th
+ while (true) {
size_t copy = std::min(length, m_segmentLength);
- memcpy(tempBuffer, m_segment, copy);
+ memcpy(dest, m_segment, copy);
m_dataPosition += copy;
kbalazs 2015/03/25 19:38:10 I also introduced an error. m_dataPosition should
length -= copy;
- tempBuffer += copy;
+ if (!length) {
+ // Done.
+ return buffer;
+ }
+ // Continue reading the next segment.
+ dest += copy;
m_segmentLength = m_data->getSomeData(m_segment, m_dataPosition);
ASSERT(m_segmentLength);
}
- return buffer;
+
+ ASSERT_NOT_REACHED();
Peter Kasting 2015/03/20 01:10:42 I think these two lines will trigger MSVC warning
kbalazs 2015/03/20 20:20:42 Acknowledged.
+ return 0;
}
size_t FastSharedBufferReader::getSomeData(const char*& someData, size_t dataPosition)

Powered by Google App Engine
This is Rietveld 408576698