| Index: xfa/fxfa/app/xfa_ffapp.cpp
|
| diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp
|
| index c5dcad848cd7ca9752401c053c2669ec4fe52287..0910326f27e6d4d97e747fed725c0bfc48b35bd1 100644
|
| --- a/xfa/fxfa/app/xfa_ffapp.cpp
|
| +++ b/xfa/fxfa/app/xfa_ffapp.cpp
|
| @@ -20,25 +20,31 @@
|
| #include "xfa/fxfa/xfa_fontmgr.h"
|
|
|
| CXFA_FileRead::CXFA_FileRead(const std::vector<CPDF_Stream*>& streams) {
|
| + m_FileSize = 0;
|
| + m_nCurPos = 0;
|
| for (CPDF_Stream* pStream : streams) {
|
| CPDF_StreamAcc& acc = m_Data.Add();
|
| acc.LoadAllData(pStream);
|
| + m_FileSize += pdfium::base::checked_cast<FX_FILESIZE>(acc.GetSize());
|
| }
|
| }
|
|
|
| CXFA_FileRead::~CXFA_FileRead() {}
|
|
|
| +bool CXFA_FileRead::IsEOF() {
|
| + return m_nCurPos >= GetSize();
|
| +}
|
| +
|
| FX_FILESIZE CXFA_FileRead::GetSize() {
|
| - uint32_t dwSize = 0;
|
| - int32_t iCount = m_Data.GetSize();
|
| - for (int32_t i = 0; i < iCount; i++) {
|
| - CPDF_StreamAcc& acc = m_Data[i];
|
| - dwSize += acc.GetSize();
|
| - }
|
| - return dwSize;
|
| + return m_FileSize;
|
| }
|
|
|
| -bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
|
| +size_t CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
|
| + if (offset < 0 || GetSize() < offset) {
|
| + return 0;
|
| + }
|
| + size_t readSize =
|
| + std::min(pdfium::base::checked_cast<size_t>(GetSize() - offset), size);
|
| int32_t iCount = m_Data.GetSize();
|
| int32_t index = 0;
|
| while (index < iCount) {
|
| @@ -57,13 +63,13 @@ bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
|
| FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead);
|
| size -= dwRead;
|
| if (size == 0) {
|
| - return true;
|
| + break;
|
| }
|
| buffer = (uint8_t*)buffer + dwRead;
|
| offset = 0;
|
| index++;
|
| }
|
| - return false;
|
| + return readSize;
|
| }
|
|
|
| void CXFA_FileRead::Release() {
|
|
|