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

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

Issue 1011113003: Fix potential bug in FastSharedBufferReader::getConsecutiveData (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: back to v6 plus define Created 5 years, 8 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 | « Source/platform/image-decoders/FastSharedBufferReader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/image-decoders/FastSharedBufferReaderTest.cpp
diff --git a/Source/platform/image-decoders/FastSharedBufferReaderTest.cpp b/Source/platform/image-decoders/FastSharedBufferReaderTest.cpp
index 2a989f9b0e7e1e8cdf40a78a3119e92f32a20fb0..3479ac1fa674566982f114a7f3ef4756b2600170 100644
--- a/Source/platform/image-decoders/FastSharedBufferReaderTest.cpp
+++ b/Source/platform/image-decoders/FastSharedBufferReaderTest.cpp
@@ -38,6 +38,8 @@ namespace blink {
namespace {
+const unsigned kDefaultTestSize = 4 * SharedBuffer::kSegmentSize;
+
void prepareReferenceData(char* buffer, size_t size)
{
for (size_t i = 0; i < size; ++i)
@@ -48,8 +50,7 @@ void prepareReferenceData(char* buffer, size_t size)
TEST(FastSharedBufferReaderTest, nonSequentialReads)
{
- // This is 4 times SharedBuffer's segment size.
- char referenceData[16384];
+ char referenceData[kDefaultTestSize];
prepareReferenceData(referenceData, sizeof(referenceData));
RefPtr<SharedBuffer> data = SharedBuffer::create();
data->append(referenceData, sizeof(referenceData));
@@ -68,8 +69,7 @@ TEST(FastSharedBufferReaderTest, nonSequentialReads)
TEST(FastSharedBufferReaderTest, readBackwards)
{
- // This is 4 times SharedBuffer's segment size.
- char referenceData[16384];
+ char referenceData[kDefaultTestSize];
prepareReferenceData(referenceData, sizeof(referenceData));
RefPtr<SharedBuffer> data = SharedBuffer::create();
data->append(referenceData, sizeof(referenceData));
@@ -88,8 +88,7 @@ TEST(FastSharedBufferReaderTest, readBackwards)
TEST(FastSharedBufferReaderTest, byteByByte)
{
- // This is 4 times SharedBuffer's segment size.
- char referenceData[16384];
+ char referenceData[kDefaultTestSize];
prepareReferenceData(referenceData, sizeof(referenceData));
RefPtr<SharedBuffer> data = SharedBuffer::create();
data->append(referenceData, sizeof(referenceData));
@@ -100,4 +99,21 @@ TEST(FastSharedBufferReaderTest, byteByByte)
}
}
+// Tests that a read from inside the penultimate segment to the very end of the
+// buffer doesn't try to read off the end of the buffer.
+TEST(FastSharedBufferReaderTest, readAllOverlappingLastSegmentBoundary)
+{
+ const unsigned dataSize = 2 * SharedBuffer::kSegmentSize;
+ char referenceData[dataSize];
+ prepareReferenceData(referenceData, dataSize);
+ RefPtr<SharedBuffer> data = SharedBuffer::create();
+ data->append(referenceData, dataSize);
+
+ char buffer[dataSize];
+ FastSharedBufferReader reader(data);
+ reader.getConsecutiveData(0, dataSize, buffer);
+
+ ASSERT_FALSE(memcmp(buffer, referenceData, dataSize));
+}
+
} // namespace blink
« no previous file with comments | « Source/platform/image-decoders/FastSharedBufferReader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698