diff options
Diffstat (limited to 'core')
20 files changed, 42 insertions, 34 deletions
diff --git a/core/fpdfapi/edit/cpdf_flateencoder.cpp b/core/fpdfapi/edit/cpdf_flateencoder.cpp index f8e2b5ad55..555da84244 100644 --- a/core/fpdfapi/edit/cpdf_flateencoder.cpp +++ b/core/fpdfapi/edit/cpdf_flateencoder.cpp @@ -14,12 +14,12 @@ CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, bool bFlateEncode) : m_dwSize(0), m_pAcc(pdfium::MakeRetain<CPDF_StreamAcc>(pStream)) { - m_pAcc->LoadAllData(true); + m_pAcc->LoadAllDataRaw(); bool bHasFilter = pStream && pStream->HasFilter(); if (bHasFilter && !bFlateEncode) { auto pDestAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - pDestAcc->LoadAllData(); + pDestAcc->LoadAllDataFiltered(); m_dwSize = pDestAcc->GetSize(); m_pData = pDestAcc->DetachData(); diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 082b5039e3..21f8addf8f 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -374,7 +374,7 @@ bool CPDF_CIDFont::Load() { return false; } else if (CPDF_Stream* pStream = pEncoding->AsStream()) { auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - pAcc->LoadAllData(false); + pAcc->LoadAllDataFiltered(); m_pCMap = pdfium::MakeRetain<CPDF_CMap>(); m_pCMap->LoadEmbedded(pAcc->GetData(), pAcc->GetSize()); } else { @@ -412,7 +412,7 @@ bool CPDF_CIDFont::Load() { if (pmap) { if (CPDF_Stream* pStream = pmap->AsStream()) { m_pStreamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - m_pStreamAcc->LoadAllData(false); + m_pStreamAcc->LoadAllDataFiltered(); } else if (pmap->GetString() == "Identity") { #if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ if (m_pFontFile) diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp index 0ddaa34e13..0b746d7bfc 100644 --- a/core/fpdfapi/font/cpdf_tounicodemap.cpp +++ b/core/fpdfapi/font/cpdf_tounicodemap.cpp @@ -125,7 +125,7 @@ uint32_t CPDF_ToUnicodeMap::GetUnicode() { void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { CIDSet cid_set = CIDSET_UNKNOWN; auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - pAcc->LoadAllData(false); + pAcc->LoadAllDataFiltered(); CPDF_SimpleParser parser(pAcc->GetData(), pAcc->GetSize()); while (1) { ByteStringView word = parser.GetWord(); diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index f9214c75d6..c09562ce52 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -1031,7 +1031,7 @@ bool CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, m_Table = pString->GetString(); } else if (CPDF_Stream* pStream = pTableObj->AsStream()) { auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - pAcc->LoadAllData(false); + pAcc->LoadAllDataFiltered(); m_Table = ByteStringView(pAcc->GetData(), pAcc->GetSize()); } return true; diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp index cc93b4df9e..93151af305 100644 --- a/core/fpdfapi/page/cpdf_contentparser.cpp +++ b/core/fpdfapi/page/cpdf_contentparser.cpp @@ -37,7 +37,7 @@ CPDF_ContentParser::CPDF_ContentParser(CPDF_Page* pPage) CPDF_Stream* pStream = pContent->AsStream(); if (pStream) { m_pSingleStream = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - m_pSingleStream->LoadAllData(false); + m_pSingleStream->LoadAllDataFiltered(); return; } CPDF_Array* pArray = pContent->AsArray(); @@ -102,7 +102,7 @@ CPDF_ContentParser::CPDF_ContentParser(CPDF_Form* pForm, } m_pSingleStream = pdfium::MakeRetain<CPDF_StreamAcc>(pForm->m_pFormStream.Get()); - m_pSingleStream->LoadAllData(false); + m_pSingleStream->LoadAllDataFiltered(); m_pData.Reset(m_pSingleStream->GetData()); m_Size = m_pSingleStream->GetSize(); } @@ -149,7 +149,7 @@ bool CPDF_ContentParser::Continue(IFX_PauseIndicator* pPause) { pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr); m_StreamArray[m_CurrentOffset] = pdfium::MakeRetain<CPDF_StreamAcc>(pStreamObj); - m_StreamArray[m_CurrentOffset]->LoadAllData(false); + m_StreamArray[m_CurrentOffset]->LoadAllDataFiltered(); m_CurrentOffset++; } } diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp index 31d6bae63f..dc2554f92d 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.cpp +++ b/core/fpdfapi/page/cpdf_docpagedata.cpp @@ -417,7 +417,7 @@ RetainPtr<CPDF_IccProfile> CPDF_DocPageData::GetIccProfile( return it->second; auto pAccessor = pdfium::MakeRetain<CPDF_StreamAcc>(pProfileStream); - pAccessor->LoadAllData(false); + pAccessor->LoadAllDataFiltered(); uint8_t digest[20]; CRYPT_SHA1Generate(pAccessor->GetData(), pAccessor->GetSize(), digest); @@ -457,7 +457,7 @@ RetainPtr<CPDF_StreamAcc> CPDF_DocPageData::GetFontFileStreamAcc( org_size = std::max(org_size, 0); auto pFontAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pFontStream); - pFontAcc->LoadAllData(false, org_size); + pFontAcc->LoadAllData(false, org_size, false); m_FontFileMap[pFontStream] = pFontAcc; return pFontAcc; } diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp index 1850efde9c..083acce68a 100644 --- a/core/fpdfapi/page/cpdf_meshstream.cpp +++ b/core/fpdfapi/page/cpdf_meshstream.cpp @@ -116,7 +116,7 @@ CPDF_MeshStream::CPDF_MeshStream( CPDF_MeshStream::~CPDF_MeshStream() {} bool CPDF_MeshStream::Load() { - m_pStream->LoadAllData(); + m_pStream->LoadAllDataFiltered(); m_BitStream = pdfium::MakeUnique<CFX_BitStream>(m_pStream->GetData(), m_pStream->GetSize()); CPDF_Dictionary* pDict = m_pShadingStream->GetDict(); diff --git a/core/fpdfapi/page/cpdf_psfunc.cpp b/core/fpdfapi/page/cpdf_psfunc.cpp index debbbd6e6d..9f101eb91b 100644 --- a/core/fpdfapi/page/cpdf_psfunc.cpp +++ b/core/fpdfapi/page/cpdf_psfunc.cpp @@ -15,7 +15,7 @@ CPDF_PSFunc::~CPDF_PSFunc() {} bool CPDF_PSFunc::v_Init(CPDF_Object* pObj) { auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pObj->AsStream()); - pAcc->LoadAllData(false); + pAcc->LoadAllDataFiltered(); return m_PS.Parse(reinterpret_cast<const char*>(pAcc->GetData()), pAcc->GetSize()); } diff --git a/core/fpdfapi/page/cpdf_sampledfunc.cpp b/core/fpdfapi/page/cpdf_sampledfunc.cpp index 91c6b5a70a..98e1fd03e0 100644 --- a/core/fpdfapi/page/cpdf_sampledfunc.cpp +++ b/core/fpdfapi/page/cpdf_sampledfunc.cpp @@ -51,7 +51,7 @@ bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample); m_pSampleStream = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - m_pSampleStream->LoadAllData(false); + m_pSampleStream->LoadAllDataFiltered(); FX_SAFE_UINT32 nTotalSampleBits = 1; m_EncodeInfo.resize(m_nInputs); for (uint32_t i = 0; i < m_nInputs; i++) { diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp index e8f0265ae4..d963df4887 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp +++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp @@ -327,7 +327,7 @@ std::unique_ptr<CPDF_Object> CPDF_CryptoHandler::DecryptObjectTree( // TODO(art-snake): Move decryption into the CPDF_Stream class. CPDF_Stream* stream = child->AsStream(); auto stream_access = pdfium::MakeRetain<CPDF_StreamAcc>(stream); - stream_access->LoadAllData(true); + stream_access->LoadAllDataRaw(); if (IsCipherAES() && stream_access->GetSize() < 16) { stream->SetData(nullptr, 0); diff --git a/core/fpdfapi/parser/cpdf_hint_tables.cpp b/core/fpdfapi/parser/cpdf_hint_tables.cpp index 2b58e9d8f3..c9123d4b97 100644 --- a/core/fpdfapi/parser/cpdf_hint_tables.cpp +++ b/core/fpdfapi/parser/cpdf_hint_tables.cpp @@ -471,7 +471,7 @@ bool CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) { return false; auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pHintStream); - pAcc->LoadAllData(); + pAcc->LoadAllDataFiltered(); uint32_t size = pAcc->GetSize(); // The header section of page offset hint table is 36 bytes. diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index 4e77773a3b..0d1b02a5ce 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -1096,7 +1096,7 @@ bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) { uint32_t totalWidth = dwAccWidth.ValueOrDie(); auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - pAcc->LoadAllData(); + pAcc->LoadAllDataFiltered(); const uint8_t* pData = pAcc->GetData(); uint32_t dwTotalSize = pAcc->GetSize(); @@ -1250,7 +1250,7 @@ RetainPtr<CPDF_StreamAcc> CPDF_Parser::GetObjectStream(uint32_t objnum) { return nullptr; auto pStreamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - pStreamAcc->LoadAllData(); + pStreamAcc->LoadAllDataFiltered(); m_ObjectStreamMap[objnum] = pStreamAcc; return pStreamAcc; } diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp index bf2feaed22..074e747a78 100644 --- a/core/fpdfapi/parser/cpdf_stream.cpp +++ b/core/fpdfapi/parser/cpdf_stream.cpp @@ -80,7 +80,7 @@ std::unique_ptr<CPDF_Object> CPDF_Stream::CloneNonCyclic( std::set<const CPDF_Object*>* pVisited) const { pVisited->insert(this); auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(this); - pAcc->LoadAllData(true); + pAcc->LoadAllDataRaw(); uint32_t streamSize = pAcc->GetSize(); CPDF_Dictionary* pDict = GetDict(); @@ -147,7 +147,7 @@ bool CPDF_Stream::HasFilter() const { WideString CPDF_Stream::GetUnicodeText() const { auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(this); - pAcc->LoadAllData(false); + pAcc->LoadAllDataFiltered(); return PDF_DecodeText(pAcc->GetData(), pAcc->GetSize()); } @@ -156,7 +156,7 @@ bool CPDF_Stream::WriteTo(IFX_ArchiveStream* archive) const { return false; auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(this); - pAcc->LoadAllData(true); + pAcc->LoadAllDataRaw(); return archive->WriteBlock(pAcc->GetData(), pAcc->GetSize()) && archive->WriteString("\r\nendstream"); } diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp index 5792a80d14..d115b48226 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.cpp +++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp @@ -56,6 +56,14 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess, m_bNewBuf = m_pData != m_pStream->GetRawData(); } +void CPDF_StreamAcc::LoadAllDataFiltered() { + LoadAllData(false, 0, false); +} + +void CPDF_StreamAcc::LoadAllDataRaw() { + LoadAllData(true, 0, false); +} + CPDF_Dictionary* CPDF_StreamAcc::GetDict() const { return m_pStream ? m_pStream->GetDict() : nullptr; } diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h index 52ac7e2e05..d54e000097 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.h +++ b/core/fpdfapi/parser/cpdf_stream_acc.h @@ -23,9 +23,9 @@ class CPDF_StreamAcc : public Retainable { CPDF_StreamAcc(const CPDF_StreamAcc&) = delete; CPDF_StreamAcc& operator=(const CPDF_StreamAcc&) = delete; - void LoadAllData(bool bRawAccess = false, - uint32_t estimated_size = 0, - bool bImageAcc = false); + void LoadAllData(bool bRawAccess, uint32_t estimated_size, bool bImageAcc); + void LoadAllDataFiltered(); + void LoadAllDataRaw(); const CPDF_Stream* GetStream() const { return m_pStream.Get(); } CPDF_Dictionary* GetDict() const; diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp index 2185e88ff6..45284a4ceb 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp @@ -209,7 +209,7 @@ std::ostream& operator<<(std::ostream& buf, const CPDF_Object* pObj) { const CPDF_Stream* p = pObj->AsStream(); buf << p->GetDict() << "stream\r\n"; auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(p); - pAcc->LoadAllData(true); + pAcc->LoadAllDataRaw(); buf.write(reinterpret_cast<const char*>(pAcc->GetData()), pAcc->GetSize()); buf << "\r\nendstream"; diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp index 3cd18909eb..d8ddc767ba 100644 --- a/core/fpdfapi/render/cpdf_dibsource.cpp +++ b/core/fpdfapi/render/cpdf_dibsource.cpp @@ -328,7 +328,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_PauseIndicator* pPause) { m_pStreamAcc->GetImageParam()->GetStreamFor("JBIG2Globals"); if (pGlobals) { m_pGlobalStream = pdfium::MakeRetain<CPDF_StreamAcc>(pGlobals); - m_pGlobalStream->LoadAllData(false); + m_pGlobalStream->LoadAllDataFiltered(); } } iDecodeStatus = pJbig2Module->StartDecode( diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp index b31348aa0b..efe3c29dbf 100644 --- a/core/fpdfdoc/cpdf_metadata.cpp +++ b/core/fpdfdoc/cpdf_metadata.cpp @@ -21,7 +21,7 @@ CPDF_Metadata::CPDF_Metadata(const CPDF_Document* pDoc) { return; auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); - pAcc->LoadAllData(false); + pAcc->LoadAllDataFiltered(); m_pXmlElement = CXML_Element::Parse(pAcc->GetData(), pAcc->GetSize()); } diff --git a/core/fxcodec/jbig2/JBig2_BitStream_unittest.cpp b/core/fxcodec/jbig2/JBig2_BitStream_unittest.cpp index 7b91eff982..b66d8b0651 100644 --- a/core/fxcodec/jbig2/JBig2_BitStream_unittest.cpp +++ b/core/fxcodec/jbig2/JBig2_BitStream_unittest.cpp @@ -17,7 +17,7 @@ TEST(JBig2_BitStream, ReadNBits) { auto in_stream = pdfium::MakeUnique<CPDF_Stream>(std::move(data), 1, nullptr); auto acc = pdfium::MakeRetain<CPDF_StreamAcc>(in_stream.get()); - acc->LoadAllData(); + acc->LoadAllDataFiltered(); CJBig2_BitStream stream(acc); @@ -42,7 +42,7 @@ TEST(JBig2_BitStream, ReadNBitsLargerThenData) { auto in_stream = pdfium::MakeUnique<CPDF_Stream>(std::move(data), 1, nullptr); auto acc = pdfium::MakeRetain<CPDF_StreamAcc>(in_stream.get()); - acc->LoadAllData(); + acc->LoadAllDataFiltered(); CJBig2_BitStream stream(acc); @@ -54,7 +54,7 @@ TEST(JBig2_BitStream, ReadNBitsLargerThenData) { TEST(JBig2_BitStream, ReadNBitsNullStream) { auto in_stream = pdfium::MakeUnique<CPDF_Stream>(nullptr, 0, nullptr); auto acc = pdfium::MakeRetain<CPDF_StreamAcc>(in_stream.get()); - acc->LoadAllData(); + acc->LoadAllDataFiltered(); CJBig2_BitStream stream(acc); @@ -70,7 +70,7 @@ TEST(JBig2_BitStream, ReadNBitsEmptyStream) { auto in_stream = pdfium::MakeUnique<CPDF_Stream>(std::move(data), 0, nullptr); auto acc = pdfium::MakeRetain<CPDF_StreamAcc>(in_stream.get()); - acc->LoadAllData(); + acc->LoadAllDataFiltered(); CJBig2_BitStream stream(acc); @@ -87,7 +87,7 @@ TEST(JBig2_BitStream, ReadNBitsOutOfBounds) { auto in_stream = pdfium::MakeUnique<CPDF_Stream>(std::move(data), 1, nullptr); auto acc = pdfium::MakeRetain<CPDF_StreamAcc>(in_stream.get()); - acc->LoadAllData(); + acc->LoadAllDataFiltered(); CJBig2_BitStream stream(acc); @@ -108,7 +108,7 @@ TEST(JBig2_BitStream, ReadNBitsWhereNIs36) { auto in_stream = pdfium::MakeUnique<CPDF_Stream>(std::move(data), 5, nullptr); auto acc = pdfium::MakeRetain<CPDF_StreamAcc>(in_stream.get()); - acc->LoadAllData(); + acc->LoadAllDataFiltered(); CJBig2_BitStream stream(acc); diff --git a/core/fxcrt/cfx_seekablemultistream.cpp b/core/fxcrt/cfx_seekablemultistream.cpp index 12682d7678..92286b1939 100644 --- a/core/fxcrt/cfx_seekablemultistream.cpp +++ b/core/fxcrt/cfx_seekablemultistream.cpp @@ -16,7 +16,7 @@ CFX_SeekableMultiStream::CFX_SeekableMultiStream( const std::vector<CPDF_Stream*>& streams) { for (CPDF_Stream* pStream : streams) { m_Data.push_back(pdfium::MakeRetain<CPDF_StreamAcc>(pStream)); - m_Data.back()->LoadAllData(); + m_Data.back()->LoadAllDataFiltered(); } } |