| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fpdfapi/fpdf_page/pageint.h" | 7 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 8 | 8 |
| 9 #include <limits.h> | 9 #include <limits.h> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 CPDF_StreamParser::~CPDF_StreamParser() { | 41 CPDF_StreamParser::~CPDF_StreamParser() { |
| 42 if (m_pLastObj) { | 42 if (m_pLastObj) { |
| 43 m_pLastObj->Release(); | 43 m_pLastObj->Release(); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 FX_DWORD DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, | 47 FX_DWORD DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, |
| 48 uint8_t*& dest_buf, | 48 uint8_t*& dest_buf, |
| 49 FX_DWORD& dest_size) { | 49 FX_DWORD& dest_size) { |
| 50 if (!pDecoder) { | 50 if (!pDecoder) { |
| 51 return static_cast<FX_DWORD>(-1); | 51 return FX_INVALID_OFFSET; |
| 52 } | 52 } |
| 53 int ncomps = pDecoder->CountComps(); | 53 int ncomps = pDecoder->CountComps(); |
| 54 int bpc = pDecoder->GetBPC(); | 54 int bpc = pDecoder->GetBPC(); |
| 55 int width = pDecoder->GetWidth(); | 55 int width = pDecoder->GetWidth(); |
| 56 int height = pDecoder->GetHeight(); | 56 int height = pDecoder->GetHeight(); |
| 57 int pitch = (width * ncomps * bpc + 7) / 8; | 57 int pitch = (width * ncomps * bpc + 7) / 8; |
| 58 if (height == 0 || pitch > (1 << 30) / height) { | 58 if (height == 0 || pitch > (1 << 30) / height) { |
| 59 delete pDecoder; | 59 delete pDecoder; |
| 60 return static_cast<FX_DWORD>(-1); | 60 return FX_INVALID_OFFSET; |
| 61 } | 61 } |
| 62 dest_buf = FX_Alloc2D(uint8_t, pitch, height); | 62 dest_buf = FX_Alloc2D(uint8_t, pitch, height); |
| 63 dest_size = pitch * height; // Safe since checked alloc returned. | 63 dest_size = pitch * height; // Safe since checked alloc returned. |
| 64 for (int row = 0; row < height; row++) { | 64 for (int row = 0; row < height; row++) { |
| 65 const uint8_t* pLine = pDecoder->GetScanline(row); | 65 const uint8_t* pLine = pDecoder->GetScanline(row); |
| 66 if (!pLine) | 66 if (!pLine) |
| 67 break; | 67 break; |
| 68 | 68 |
| 69 FXSYS_memcpy(dest_buf + row * pitch, pLine, pitch); | 69 FXSYS_memcpy(dest_buf + row * pitch, pLine, pitch); |
| 70 } | 70 } |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 } | 885 } |
| 886 m_Status = Done; | 886 m_Status = Done; |
| 887 return; | 887 return; |
| 888 } | 888 } |
| 889 steps++; | 889 steps++; |
| 890 if (pPause && pPause->NeedToPauseNow()) { | 890 if (pPause && pPause->NeedToPauseNow()) { |
| 891 break; | 891 break; |
| 892 } | 892 } |
| 893 } | 893 } |
| 894 } | 894 } |
| OLD | NEW |