| Index: xfa/fxfa/app/xfa_ffapp.cpp
|
| diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp
|
| index 9e86c3aa68cf212ffd0a0aadae5751b0fa955d9a..1456ca2a7aae9ed0911dec25385a7c2efa3e9b95 100644
|
| --- a/xfa/fxfa/app/xfa_ffapp.cpp
|
| +++ b/xfa/fxfa/app/xfa_ffapp.cpp
|
| @@ -19,28 +19,31 @@
|
| #include "xfa/fxfa/include/xfa_fontmgr.h"
|
|
|
| CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) {
|
| + m_FileSize = 0;
|
| + m_nCurPos = 0;
|
| int32_t iCount = streams.GetSize();
|
| for (int32_t i = 0; i < iCount; i++) {
|
| CPDF_StreamAcc& acc = m_Data.Add();
|
| acc.LoadAllData(streams[i]);
|
| + m_FileSize += acc.GetSize();
|
| }
|
| }
|
|
|
| CXFA_FileRead::~CXFA_FileRead() {}
|
|
|
| +FX_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;
|
| }
|
|
|
| -FX_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(static_cast<size_t>(GetSize() - offset), size);
|
| int32_t iCount = m_Data.GetSize();
|
| int32_t index = 0;
|
| while (index < iCount) {
|
| @@ -59,13 +62,13 @@ FX_BOOL CXFA_FileRead::ReadBlock(void* buffer,
|
| 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() {
|
|
|