summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/page/cpdf_docpagedata.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.cpp14
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.h5
-rw-r--r--core/fpdfapi/render/cpdf_dibbase.cpp4
4 files changed, 21 insertions, 4 deletions
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index 6744e0f6a7..9ee8d588e4 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -470,7 +470,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, false);
+ pFontAcc->LoadAllDataFilteredWithEstimatedSize(org_size);
m_FontFileMap[pFontStream] = pFontAcc;
return pFontAcc;
}
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp
index 1083e3177e..78bcb57e0b 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.cpp
+++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp
@@ -20,6 +20,11 @@ CPDF_StreamAcc::~CPDF_StreamAcc() {
void CPDF_StreamAcc::LoadAllData(bool bRawAccess,
uint32_t estimated_size,
bool bImageAcc) {
+ if (bRawAccess) {
+ ASSERT(!estimated_size);
+ ASSERT(!bImageAcc);
+ }
+
if (!m_pStream)
return;
@@ -63,6 +68,15 @@ void CPDF_StreamAcc::LoadAllDataFiltered() {
LoadAllData(false, 0, false);
}
+void CPDF_StreamAcc::LoadAllDataFilteredWithEstimatedSize(
+ uint32_t estimated_size) {
+ LoadAllData(false, estimated_size, false);
+}
+
+void CPDF_StreamAcc::LoadAllDataImageAcc(uint32_t estimated_size) {
+ LoadAllData(false, estimated_size, true);
+}
+
void CPDF_StreamAcc::LoadAllDataRaw() {
LoadAllData(true, 0, false);
}
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h
index fae8ba0516..3c42639828 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.h
+++ b/core/fpdfapi/parser/cpdf_stream_acc.h
@@ -24,8 +24,9 @@ class CPDF_StreamAcc final : public Retainable {
CPDF_StreamAcc(const CPDF_StreamAcc&) = delete;
CPDF_StreamAcc& operator=(const CPDF_StreamAcc&) = delete;
- void LoadAllData(bool bRawAccess, uint32_t estimated_size, bool bImageAcc);
void LoadAllDataFiltered();
+ void LoadAllDataFilteredWithEstimatedSize(uint32_t estimated_size);
+ void LoadAllDataImageAcc(uint32_t estimated_size);
void LoadAllDataRaw();
const CPDF_Stream* GetStream() const { return m_pStream.Get(); }
@@ -44,6 +45,8 @@ class CPDF_StreamAcc final : public Retainable {
explicit CPDF_StreamAcc(const CPDF_Stream* pStream);
~CPDF_StreamAcc() override;
+ void LoadAllData(bool bRawAccess, uint32_t estimated_size, bool bImageAcc);
+
private:
uint8_t* m_pData = nullptr;
uint32_t m_dwSize = 0;
diff --git a/core/fpdfapi/render/cpdf_dibbase.cpp b/core/fpdfapi/render/cpdf_dibbase.cpp
index a37a0aecd5..d342a99ae0 100644
--- a/core/fpdfapi/render/cpdf_dibbase.cpp
+++ b/core/fpdfapi/render/cpdf_dibbase.cpp
@@ -143,7 +143,7 @@ bool CPDF_DIBBase::Load(CPDF_Document* pDoc, const CPDF_Stream* pStream) {
return false;
m_pStreamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
- m_pStreamAcc->LoadAllData(false, src_size.ValueOrDie(), true);
+ m_pStreamAcc->LoadAllDataImageAcc(src_size.ValueOrDie());
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData())
return false;
@@ -256,7 +256,7 @@ CPDF_DIBBase::LoadState CPDF_DIBBase::StartLoadDIBBase(
return LoadState::kFail;
m_pStreamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
- m_pStreamAcc->LoadAllData(false, src_size.ValueOrDie(), true);
+ m_pStreamAcc->LoadAllDataImageAcc(src_size.ValueOrDie());
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData())
return LoadState::kFail;