summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.cpp27
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.h3
2 files changed, 9 insertions, 21 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index 0b1788b0a6..acc01c65ed 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -198,7 +198,6 @@ bool CPDF_DataAvail::CheckAndLoadAllXref() {
return false;
}
- m_dwRootObjNum = m_parser.GetRootObjNum();
m_docStatus = PDF_DATAAVAIL_ROOT;
return true;
}
@@ -243,35 +242,25 @@ bool CPDF_DataAvail::CheckInfo() {
}
bool CPDF_DataAvail::CheckRoot() {
- bool bExist = false;
- m_pRoot = GetObject(m_dwRootObjNum, &bExist);
- if (!bExist) {
- m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
+ const uint32_t dwRootObjNum = m_parser.GetRootObjNum();
+ if (dwRootObjNum == CPDF_Object::kInvalidObjNum) {
+ m_docStatus = PDF_DATAAVAIL_ERROR;
return true;
}
- if (!m_pRoot) {
- if (m_docStatus == PDF_DATAAVAIL_ERROR) {
- m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
- return true;
- }
- return false;
- }
-
- CPDF_Dictionary* pDict = m_pRoot->GetDict();
- if (!pDict) {
- m_docStatus = PDF_DATAAVAIL_ERROR;
+ const CPDF_ReadValidator::Session read_session(GetValidator().Get());
+ m_pRoot = ToDictionary(m_parser.ParseIndirectObject(nullptr, dwRootObjNum));
+ if (GetValidator()->has_read_problems())
return false;
- }
- CPDF_Reference* pRef = ToReference(pDict->GetObjectFor("Pages"));
+ const CPDF_Reference* pRef =
+ ToReference(m_pRoot ? m_pRoot->GetObjectFor("Pages") : nullptr);
if (!pRef) {
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
m_PagesObjNum = pRef->GetRefObjNum();
-
m_docStatus = PDF_DATAAVAIL_INFO;
return true;
}
diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h
index 0d9b902168..8872bb103f 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.h
+++ b/core/fpdfapi/parser/cpdf_data_avail.h
@@ -165,8 +165,7 @@ class CPDF_DataAvail final {
RetainPtr<CPDF_ReadValidator> m_pFileRead;
CPDF_Parser m_parser;
- std::unique_ptr<CPDF_Object> m_pRoot;
- uint32_t m_dwRootObjNum = 0;
+ std::unique_ptr<CPDF_Dictionary> m_pRoot;
std::unique_ptr<CPDF_LinearizedHeader> m_pLinearized;
bool m_bDocAvail = false;
std::unique_ptr<CPDF_CrossRefAvail> m_pCrossRefAvail;