| Index: core/fxcrt/fx_extension.cpp
|
| diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
|
| index 4c77244b3d3a7d656ba1449c32821615c9b8ce9b..8d58de8e98306ee2e38e61719c9c705cd8915d95 100644
|
| --- a/core/fxcrt/fx_extension.cpp
|
| +++ b/core/fxcrt/fx_extension.cpp
|
| @@ -103,32 +103,33 @@ FX_FILESIZE CFX_MemoryStream::GetSize() {
|
| }
|
|
|
| FX_BOOL CFX_MemoryStream::IsEOF() {
|
| - return m_nCurPos >= (size_t)GetSize();
|
| + return m_nCurPos >= pdfium::base::checked_cast<size_t>(GetSize());
|
| }
|
|
|
| FX_FILESIZE CFX_MemoryStream::GetPosition() {
|
| return (FX_FILESIZE)m_nCurPos;
|
| }
|
|
|
| -FX_BOOL CFX_MemoryStream::ReadBlock(void* buffer,
|
| - FX_FILESIZE offset,
|
| - size_t size) {
|
| +size_t CFX_MemoryStream::ReadBlock(void* buffer,
|
| + FX_FILESIZE offset,
|
| + size_t size) {
|
| if (!buffer || !size) {
|
| - return FALSE;
|
| + return 0;
|
| }
|
|
|
| FX_SAFE_SIZE_T newPos = size;
|
| newPos += offset;
|
| if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 ||
|
| newPos.ValueOrDie() > m_nCurSize) {
|
| - return FALSE;
|
| + return 0;
|
| }
|
|
|
| m_nCurPos = newPos.ValueOrDie();
|
| if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
|
| FXSYS_memcpy(buffer, m_Blocks[0] + (size_t)offset, size);
|
| - return TRUE;
|
| + return size;
|
| }
|
| + size_t readSize = size;
|
| size_t nStartBlock = (size_t)offset / m_nGrowSize;
|
| offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize);
|
| while (size) {
|
| @@ -142,7 +143,7 @@ FX_BOOL CFX_MemoryStream::ReadBlock(void* buffer,
|
| nStartBlock++;
|
| offset = 0;
|
| }
|
| - return TRUE;
|
| + return readSize;
|
| }
|
|
|
| size_t CFX_MemoryStream::ReadBlock(void* buffer, size_t size) {
|
| @@ -150,7 +151,7 @@ size_t CFX_MemoryStream::ReadBlock(void* buffer, size_t size) {
|
| return 0;
|
| }
|
| size_t nRead = std::min(size, m_nCurSize - m_nCurPos);
|
| - if (!ReadBlock(buffer, (int32_t)m_nCurPos, nRead)) {
|
| + if (ReadBlock(buffer, (int32_t)m_nCurPos, nRead) != nRead && !IsEOF()) {
|
| return 0;
|
| }
|
| return nRead;
|
| @@ -305,10 +306,10 @@ FX_FILESIZE CFX_CRTFileStream::GetPosition() {
|
| return m_pFile->GetPosition();
|
| }
|
|
|
| -FX_BOOL CFX_CRTFileStream::ReadBlock(void* buffer,
|
| - FX_FILESIZE offset,
|
| - size_t size) {
|
| - return (FX_BOOL)m_pFile->ReadPos(buffer, size, offset);
|
| +size_t CFX_CRTFileStream::ReadBlock(void* buffer,
|
| + FX_FILESIZE offset,
|
| + size_t size) {
|
| + return m_pFile->ReadPos(buffer, size, offset);
|
| }
|
|
|
| size_t CFX_CRTFileStream::ReadBlock(void* buffer, size_t size) {
|
|
|