From 430ab8363e77c48b2c2435af4d289f85e2be1b96 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 18 Nov 2016 14:48:21 -0800 Subject: Add unit test for CXFA_FileRead. The FileRead's return convention is being modified at https://codereview.chromium.org/2430743003/, so first provide a test of the old behaviour. Fix some issues with null dictionaries as provided by the CPDF_Stream default ctor along the way. Review-Url: https://codereview.chromium.org/2517513003 --- core/fpdfapi/parser/cpdf_stream_acc.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'core/fpdfapi/parser/cpdf_stream_acc.cpp') diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp index 81439bc677..01d8e148df 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.cpp +++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp @@ -24,17 +24,16 @@ void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream, return; m_pStream = pStream; - if (pStream->IsMemoryBased() && - (!pStream->GetDict()->KeyExist("Filter") || bRawAccess)) { + if (pStream->IsMemoryBased() && (!pStream->HasFilter() || bRawAccess)) { m_dwSize = pStream->GetRawSize(); m_pData = pStream->GetRawData(); return; } - uint8_t* pSrcData; uint32_t dwSrcSize = pStream->GetRawSize(); if (dwSrcSize == 0) return; + uint8_t* pSrcData; if (!pStream->IsMemoryBased()) { pSrcData = m_pSrcData = FX_Alloc(uint8_t, dwSrcSize); if (!pStream->ReadRawData(0, pSrcData, dwSrcSize)) @@ -42,17 +41,14 @@ void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream, } else { pSrcData = pStream->GetRawData(); } - if (!pStream->GetDict()->KeyExist("Filter") || bRawAccess) { + if (!pStream->HasFilter() || bRawAccess) { + m_pData = pSrcData; + m_dwSize = dwSrcSize; + } else if (!PDF_DataDecode(pSrcData, dwSrcSize, m_pStream->GetDict(), m_pData, + m_dwSize, m_ImageDecoder, m_pImageParam, + estimated_size, bImageAcc)) { m_pData = pSrcData; m_dwSize = dwSrcSize; - } else { - bool bRet = PDF_DataDecode(pSrcData, dwSrcSize, m_pStream->GetDict(), - m_pData, m_dwSize, m_ImageDecoder, m_pImageParam, - estimated_size, bImageAcc); - if (!bRet) { - m_pData = pSrcData; - m_dwSize = dwSrcSize; - } } if (pSrcData != pStream->GetRawData() && pSrcData != m_pData) FX_Free(pSrcData); -- cgit v1.2.3