Index: core/fxcodec/codec/fx_codec_progress.cpp |
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp |
index 7d8a3203e9356000f04b94896cbf291652aa794d..f220ddc6a8b5a734eee253c10ab4e1319dd44d04 100644 |
--- a/core/fxcodec/codec/fx_codec_progress.cpp |
+++ b/core/fxcodec/codec/fx_codec_progress.cpp |
@@ -339,12 +339,13 @@ bool CCodec_ProgressiveDecoder::JpegReadMoreData(CCodec_JpegModule* pJpegModule, |
dwSize = dwConsume; |
} |
} |
- if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) { |
+ uint32_t readSize = m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize); |
+ if (readSize != dwSize && !m_pFile->IsEOF()) { |
err_status = FXCODEC_STATUS_ERR_READ; |
return false; |
} |
- m_offSet += dwSize; |
- pJpegModule->Input(m_pJpegContext, m_pSrcBuf, dwSize + dwAvail); |
+ m_offSet += readSize; |
+ pJpegModule->Input(m_pJpegContext, m_pSrcBuf, readSize + dwAvail); |
return true; |
} |
@@ -612,12 +613,13 @@ bool CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, |
dwSize = dwConsume; |
} |
} |
- if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) { |
+ uint32_t readSize = m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize); |
+ if (readSize != dwSize && !m_pFile->IsEOF()) { |
err_status = FXCODEC_STATUS_ERR_READ; |
return false; |
} |
- m_offSet += dwSize; |
- pGifModule->Input(m_pGifContext, m_pSrcBuf, dwSize + dwAvail); |
+ m_offSet += readSize; |
+ pGifModule->Input(m_pGifContext, m_pSrcBuf, readSize + dwAvail); |
return true; |
} |
@@ -902,12 +904,13 @@ bool CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, |
dwSize = dwConsume; |
} |
} |
- if (!m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize)) { |
+ uint32_t readSize = m_pFile->ReadBlock(m_pSrcBuf + dwAvail, m_offSet, dwSize); |
+ if (readSize != dwSize && !m_pFile->IsEOF()) { |
err_status = FXCODEC_STATUS_ERR_READ; |
return false; |
} |
- m_offSet += dwSize; |
- pBmpModule->Input(m_pBmpContext, m_pSrcBuf, dwSize + dwAvail); |
+ m_offSet += readSize; |
+ pBmpModule->Input(m_pBmpContext, m_pSrcBuf, readSize + dwAvail); |
return true; |
} |
@@ -1064,11 +1067,12 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, |
m_status = FXCODEC_STATUS_ERR_MEMORY; |
return false; |
} |
- bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); |
- if (!bResult) { |
+ uint32_t readSize = m_pFile->ReadBlock(m_pSrcBuf, 0, size); |
+ if (readSize != size && !m_pFile->IsEOF()) { |
m_status = FXCODEC_STATUS_ERR_READ; |
return false; |
} |
+ size = readSize; |
m_offSet += size; |
pBmpModule->Input(m_pBmpContext, m_pSrcBuf, size); |
uint32_t* pPalette = nullptr; |
@@ -1116,11 +1120,12 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, |
m_status = FXCODEC_STATUS_ERR_MEMORY; |
return false; |
} |
- bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); |
- if (!bResult) { |
+ uint32_t readSize = m_pFile->ReadBlock(m_pSrcBuf, 0, size); |
+ if (readSize != size && !m_pFile->IsEOF()) { |
m_status = FXCODEC_STATUS_ERR_READ; |
return false; |
} |
+ size = readSize; |
m_offSet += size; |
pJpegModule->Input(m_pJpegContext, m_pSrcBuf, size); |
int32_t readResult = |
@@ -1165,13 +1170,15 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, |
m_status = FXCODEC_STATUS_ERR_MEMORY; |
return false; |
} |
- bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); |
- if (!bResult) { |
+ uint32_t readSize = m_pFile->ReadBlock(m_pSrcBuf, 0, size); |
+ if (readSize != size && !m_pFile->IsEOF()) { |
m_status = FXCODEC_STATUS_ERR_READ; |
return false; |
} |
+ size = readSize; |
m_offSet += size; |
- bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, size, pAttribute); |
+ bool bResult = |
+ pPngModule->Input(m_pPngContext, m_pSrcBuf, size, pAttribute); |
while (bResult) { |
uint32_t remain_size = (uint32_t)m_pFile->GetSize() - m_offSet; |
uint32_t input_size = |
@@ -1190,14 +1197,14 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, |
FXSYS_memset(m_pSrcBuf, 0, input_size); |
m_SrcSize = input_size; |
} |
- bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); |
- if (!bResult) { |
+ uint32_t readSize = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); |
+ if (readSize != input_size && !m_pFile->IsEOF()) { |
m_status = FXCODEC_STATUS_ERR_READ; |
return false; |
} |
- m_offSet += input_size; |
+ m_offSet += readSize; |
bResult = |
- pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, pAttribute); |
+ pPngModule->Input(m_pPngContext, m_pSrcBuf, readSize, pAttribute); |
Tom Sepez
2016/11/16 18:32:01
I think we want to issue reads for the full size e
|
} |
ASSERT(!bResult); |
Tom Sepez
2016/11/16 18:32:00
This is the only use of bResult outside the loop,
|
if (m_pPngContext) { |
@@ -1229,11 +1236,12 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, |
m_status = FXCODEC_STATUS_ERR_MEMORY; |
return false; |
} |
- bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size); |
- if (!bResult) { |
+ uint32_t readSize = m_pFile->ReadBlock(m_pSrcBuf, 0, size); |
+ if (readSize != size && !m_pFile->IsEOF()) { |
m_status = FXCODEC_STATUS_ERR_READ; |
return false; |
} |
+ size = readSize; |
m_offSet += size; |
pGifModule->Input(m_pGifContext, m_pSrcBuf, size); |
Tom Sepez
2016/11/16 18:32:00
Again, do we want a full block read here?
|
m_SrcComponents = 1; |
@@ -2137,16 +2145,16 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { |
FXSYS_memset(m_pSrcBuf, 0, input_size); |
m_SrcSize = input_size; |
} |
- bool bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); |
- if (!bResult) { |
+ uint32_t readSize = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); |
+ if (readSize != input_size && !m_pFile->IsEOF()) { |
m_pDeviceBitmap = nullptr; |
m_pFile = nullptr; |
m_status = FXCODEC_STATUS_ERR_READ; |
return m_status; |
} |
- m_offSet += input_size; |
- bResult = |
- pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, nullptr); |
+ m_offSet += readSize; |
+ bool bResult = |
Tom Sepez
2016/11/16 18:32:00
nit: local not needed.
|
+ pPngModule->Input(m_pPngContext, m_pSrcBuf, readSize, nullptr); |
if (!bResult) { |
m_pDeviceBitmap = nullptr; |
m_pFile = nullptr; |