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

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

Issue 2081013002: Re-enable DrMemory test for ICOImageDecoderTests.parseAndDecodeByteByByte. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: proper fix (previous wasn't proper) Created 4 years, 6 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: third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
index f8d39b99ad264cef00633c49a40f6643b3af1b64..da081e5b4c1702134182f3714a25dacea0d7c5d8 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
@@ -48,6 +48,7 @@ ICOImageDecoder::ICOImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp
: ImageDecoder(alphaOption, colorOptions, maxDecodedBytes)
, m_fastReader(nullptr)
, m_decodedOffset(0)
+ , m_dirEntriesCount(0)
{
}
@@ -182,7 +183,7 @@ bool ICOImageDecoder::decodeDirectory()
return false;
// Read and process directory entries.
- return (m_decodedOffset >= (sizeOfDirectory + (m_dirEntries.size() * sizeOfDirEntry))) || processDirectoryEntries();
+ return (m_decodedOffset >= (sizeOfDirectory + (m_dirEntriesCount * sizeOfDirEntry))) || processDirectoryEntries();
}
bool ICOImageDecoder::decodeAtIndex(size_t index)
@@ -229,20 +230,15 @@ bool ICOImageDecoder::processDirectory()
if (m_data->size() < sizeOfDirectory)
return false;
const uint16_t fileType = readUint16(2);
- const uint16_t idCount = readUint16(4);
+ m_dirEntriesCount = readUint16(4);
m_decodedOffset = sizeOfDirectory;
// See if this is an icon filetype we understand, and make sure we have at
// least one entry in the directory.
- if (((fileType != ICON) && (fileType != CURSOR)) || (!idCount))
+ if (((fileType != ICON) && (fileType != CURSOR)) || (!m_dirEntriesCount))
return setFailed();
m_fileType = static_cast<FileType>(fileType);
-
- // Enlarge member vectors to hold all the entries.
- m_dirEntries.resize(idCount);
- m_bmpReaders.resize(idCount);
- m_pngDecoders.resize(idCount);
return true;
}
@@ -250,8 +246,14 @@ bool ICOImageDecoder::processDirectoryEntries()
{
// Read directory entries.
ASSERT(m_decodedOffset == sizeOfDirectory);
- if ((m_decodedOffset > m_data->size()) || ((m_data->size() - m_decodedOffset) < (m_dirEntries.size() * sizeOfDirEntry)))
+ if ((m_decodedOffset > m_data->size()) || ((m_data->size() - m_decodedOffset) < (m_dirEntriesCount * sizeOfDirEntry)))
return false;
+
+ // Enlarge member vectors to hold all the entries.
+ m_dirEntries.resize(m_dirEntriesCount);
+ m_bmpReaders.resize(m_dirEntriesCount);
+ m_pngDecoders.resize(m_dirEntriesCount);
+
for (IconDirectoryEntries::iterator i(m_dirEntries.begin()); i != m_dirEntries.end(); ++i)
*i = readDirectoryEntry(); // Updates m_decodedOffset.

Powered by Google App Engine
This is Rietveld 408576698