summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-06-06 16:52:34 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-06 16:52:34 +0000
commit4f01c0e5eb5f1054e003e34a690c8919ccd8642d (patch)
tree1a275d77718bcd3eddca1e3e92550456c88271eb /core/fpdfapi
parentce4b14ef28ea4c78fe07f271c7185fe9766f7c55 (diff)
downloadpdfium-4f01c0e5eb5f1054e003e34a690c8919ccd8642d.tar.xz
Simplify check root availability.
Change-Id: I34403490672b752bed9d5b6b29e8f4422c0fbf95 Reviewed-on: https://pdfium-review.googlesource.com/17732 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-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;