OLD | NEW |
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
4 * | 4 * |
5 * The contents of this file are subject to the Mozilla Public License Version | 5 * The contents of this file are subject to the Mozilla Public License Version |
6 * 1.1 (the "License"); you may not use this file except in compliance with | 6 * 1.1 (the "License"); you may not use this file except in compliance with |
7 * the License. You may obtain a copy of the License at | 7 * the License. You may obtain a copy of the License at |
8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
9 * | 9 * |
10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 m_lzwContext = adoptPtr(new GIFLZWContext(client, this)); | 337 m_lzwContext = adoptPtr(new GIFLZWContext(client, this)); |
338 if (!m_lzwContext->prepareToDecode()) { | 338 if (!m_lzwContext->prepareToDecode()) { |
339 m_lzwContext.clear(); | 339 m_lzwContext.clear(); |
340 return false; | 340 return false; |
341 } | 341 } |
342 | 342 |
343 m_currentLzwBlock = 0; | 343 m_currentLzwBlock = 0; |
344 } | 344 } |
345 | 345 |
| 346 if (m_lzwContext->hasRemainingRows()) { |
| 347 if (!client->initFrameBuffer(m_frameId)) |
| 348 return false; |
| 349 } |
| 350 |
346 // Some bad GIFs have extra blocks beyond the last row, which we don't want
to decode. | 351 // Some bad GIFs have extra blocks beyond the last row, which we don't want
to decode. |
347 while (m_currentLzwBlock < m_lzwBlocks.size() && m_lzwContext->hasRemainingR
ows()) { | 352 while (m_currentLzwBlock < m_lzwBlocks.size() && m_lzwContext->hasRemainingR
ows()) { |
348 size_t blockPosition = m_lzwBlocks[m_currentLzwBlock].blockPosition; | 353 size_t blockPosition = m_lzwBlocks[m_currentLzwBlock].blockPosition; |
349 size_t blockSize = m_lzwBlocks[m_currentLzwBlock].blockSize; | 354 size_t blockSize = m_lzwBlocks[m_currentLzwBlock].blockSize; |
350 if (blockPosition + blockSize > reader->size()) | 355 if (blockPosition + blockSize > reader->size()) |
351 return false; | 356 return false; |
352 | 357 |
353 while (blockSize) { | 358 while (blockSize) { |
354 const char* segment = 0; | 359 const char* segment = 0; |
355 size_t segmentLength = reader->getSomeData(segment, blockPosition); | 360 size_t segmentLength = reader->getSomeData(segment, blockPosition); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 rowIter = rowBuffer.begin(); | 846 rowIter = rowBuffer.begin(); |
842 rowsRemaining = m_frameContext->height(); | 847 rowsRemaining = m_frameContext->height(); |
843 | 848 |
844 // Clearing the whole suffix table lets us be more tolerant of bad data. | 849 // Clearing the whole suffix table lets us be more tolerant of bad data. |
845 for (int i = 0; i < clearCode; ++i) { | 850 for (int i = 0; i < clearCode; ++i) { |
846 suffix[i] = i; | 851 suffix[i] = i; |
847 suffixLength[i] = 1; | 852 suffixLength[i] = 1; |
848 } | 853 } |
849 return true; | 854 return true; |
850 } | 855 } |
OLD | NEW |