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

Unified Diff: Source/platform/image-decoders/ico/ICOImageDecoder.cpp

Issue 733063005: Don't decode AND mask for an icon that already has alpha information (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Clamp size later. Created 6 years, 1 month 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/ico/ICOImageDecoder.h ('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/ico/ICOImageDecoder.cpp
diff --git a/Source/platform/image-decoders/ico/ICOImageDecoder.cpp b/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
index 06dce8e51035e6f192292e52224884faebbab5c7..14bf784db393d90e9bc9228cdbf2883fccf4161c 100644
--- a/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
+++ b/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
@@ -216,8 +216,11 @@ bool ICOImageDecoder::decodeAtIndex(size_t index)
// We need to have already sized m_frameBufferCache before this, and
// we must not resize it again later (see caution in frameCount()).
ASSERT(m_frameBufferCache.size() == m_dirEntries.size());
- m_bmpReaders[index] = adoptPtr(new BMPImageReader(this, dirEntry.m_imageOffset, 0, true));
- m_bmpReaders[index]->setData(m_data.get());
+ // Make sure the image data doesn't go beyond the end of the file.
+ uint32_t imageSize = std::min(dirEntry.m_imageSize, m_data->size() - dirEntry.m_imageOffset);
+ RefPtr<SharedBuffer> bmpData(SharedBuffer::create(&m_data->data()[dirEntry.m_imageOffset], imageSize));
+ m_bmpReaders[index] = adoptPtr(new BMPImageReader(this, 0, 0, true));
+ m_bmpReaders[index]->setData(bmpData.get());
Peter Kasting 2014/11/18 20:59:05 I have three concerns with this code, in decreasin
m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]);
}
m_frameSize = dirEntry.m_size;
@@ -314,6 +317,7 @@ ICOImageDecoder::IconDirectoryEntry ICOImageDecoder::readDirectoryEntry()
entry.m_bitCount = readUint16(6);
entry.m_hotSpot = IntPoint();
}
+ entry.m_imageSize = readUint32(8);
entry.m_imageOffset = readUint32(12);
// Some icons don't have a bit depth, only a color count. Convert the
« no previous file with comments | « Source/platform/image-decoders/ico/ICOImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698