diff options
Diffstat (limited to 'WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp')
-rw-r--r-- | WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp b/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp index bc4f357..e9296ad 100644 --- a/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp +++ b/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp @@ -249,7 +249,7 @@ bool ICOImageDecoder::processDirectory() ICON = 1, CURSOR = 2, }; - if (((fileType != ICON) && (fileType != CURSOR)) || (!idCount)) { + if (((fileType != ICON) && (fileType != CURSOR)) || (idCount == 0)) { setFailed(); return false; } @@ -303,10 +303,10 @@ ICOImageDecoder::IconDirectoryEntry ICOImageDecoder::readDirectoryEntry() // matching uint8_ts) is so we can record dimensions of size 256 (which is // what a zero byte really means). int width = static_cast<uint8_t>(m_data->data()[m_decodedOffset]); - if (!width) + if (width == 0) width = 256; int height = static_cast<uint8_t>(m_data->data()[m_decodedOffset + 1]); - if (!height) + if (height == 0) height = 256; IconDirectoryEntry entry; entry.m_size = IntSize(width, height); @@ -318,12 +318,11 @@ ICOImageDecoder::IconDirectoryEntry ICOImageDecoder::readDirectoryEntry() // this isn't quite what the bitmap info header says later, as we only use // this value to determine which icon entry is best. if (!entry.m_bitCount) { - int colorCount = - static_cast<uint8_t>(m_data->data()[m_decodedOffset + 2]); - if (!colorCount) - colorCount = 256; // Vague in the spec, needed by real-world icons. - for (--colorCount; colorCount; colorCount >>= 1) - ++entry.m_bitCount; + uint8_t colorCount = m_data->data()[m_decodedOffset + 2]; + if (colorCount) { + for (--colorCount; colorCount; colorCount >>= 1) + ++entry.m_bitCount; + } } m_decodedOffset += sizeOfDirEntry; |