Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 size_t ICOImageDecoder::decodeFrameCount() | 129 size_t ICOImageDecoder::decodeFrameCount() |
| 130 { | 130 { |
| 131 decodeSize(); | 131 decodeSize(); |
| 132 | 132 |
| 133 // If decodeSize() fails, return the existing number of frames. This way | 133 // If decodeSize() fails, return the existing number of frames. This way |
| 134 // if we get halfway through the image before decoding fails, we won't | 134 // if we get halfway through the image before decoding fails, we won't |
| 135 // suddenly start reporting that the image has zero frames. | 135 // suddenly start reporting that the image has zero frames. |
| 136 if (failed()) | 136 if (failed()) |
| 137 return m_frameBufferCache.size(); | 137 return m_frameBufferCache.size(); |
| 138 | 138 |
| 139 // Check if there is enough data available to parse directory entries. | |
| 140 if (m_decodedOffset < sizeOfDirectory + m_dirEntries.size() * sizeOfDirector y) | |
|
Peter Kasting
2016/06/22 23:35:28
Is the problem here as follows?:
* Someone calls
aleksandar.stojiljkovic
2016/06/23 10:11:29
Yes, that's the problem.
Used your approach with t
| |
| 141 return 0; | |
| 142 | |
| 139 // Length of sequence of completely received frames. | 143 // Length of sequence of completely received frames. |
| 140 for (size_t i = 0; i < m_dirEntries.size(); ++i) { | 144 for (size_t i = 0; i < m_dirEntries.size(); ++i) { |
| 141 const IconDirectoryEntry& dirEntry = m_dirEntries[i]; | 145 const IconDirectoryEntry& dirEntry = m_dirEntries[i]; |
| 142 if ((dirEntry.m_imageOffset + dirEntry.m_byteSize) > m_data->size()) | 146 if ((dirEntry.m_imageOffset + dirEntry.m_byteSize) > m_data->size()) |
| 143 return i; | 147 return i; |
| 144 } | 148 } |
| 145 return m_dirEntries.size(); | 149 return m_dirEntries.size(); |
| 146 } | 150 } |
| 147 | 151 |
| 148 void ICOImageDecoder::setDataForPNGDecoderAtIndex(size_t index) | 152 void ICOImageDecoder::setDataForPNGDecoderAtIndex(size_t index) |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size()); | 329 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size()); |
| 326 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; | 330 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; |
| 327 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) | 331 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) |
| 328 return Unknown; | 332 return Unknown; |
| 329 char buffer[4]; | 333 char buffer[4]; |
| 330 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); | 334 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); |
| 331 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; | 335 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; |
| 332 } | 336 } |
| 333 | 337 |
| 334 } // namespace blink | 338 } // namespace blink |
| OLD | NEW |