diff options
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 21 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 18 |
3 files changed, 20 insertions, 20 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index cc75ee37f1..0b1788b0a6 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -199,7 +199,6 @@ bool CPDF_DataAvail::CheckAndLoadAllXref() { } m_dwRootObjNum = m_parser.GetRootObjNum(); - m_dwInfoObjNum = m_parser.GetInfoObjNum(); m_docStatus = PDF_DATAAVAIL_ROOT; return true; } @@ -228,15 +227,17 @@ std::unique_ptr<CPDF_Object> CPDF_DataAvail::GetObject(uint32_t objnum, } bool CPDF_DataAvail::CheckInfo() { - bool bExist = false; - std::unique_ptr<CPDF_Object> pInfo = GetObject(m_dwInfoObjNum, &bExist); - if (bExist && !pInfo) { - if (m_docStatus == PDF_DATAAVAIL_ERROR) { - m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return true; - } - return false; + const uint32_t dwInfoObjNum = m_parser.GetInfoObjNum(); + if (dwInfoObjNum == CPDF_Object::kInvalidObjNum) { + m_docStatus = PDF_DATAAVAIL_PAGETREE; + return true; } + + const CPDF_ReadValidator::Session read_session(GetValidator().Get()); + m_parser.ParseIndirectObject(nullptr, dwInfoObjNum); + if (GetValidator()->has_read_problems()) + return false; + m_docStatus = PDF_DATAAVAIL_PAGETREE; return true; } @@ -271,7 +272,7 @@ bool CPDF_DataAvail::CheckRoot() { m_PagesObjNum = pRef->GetRefObjNum(); - m_docStatus = m_dwInfoObjNum ? PDF_DATAAVAIL_INFO : PDF_DATAAVAIL_PAGETREE; + 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 2ea93fa759..0d9b902168 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -167,7 +167,6 @@ class CPDF_DataAvail final { CPDF_Parser m_parser; std::unique_ptr<CPDF_Object> m_pRoot; uint32_t m_dwRootObjNum = 0; - uint32_t m_dwInfoObjNum = 0; std::unique_ptr<CPDF_LinearizedHeader> m_pLinearized; bool m_bDocAvail = false; std::unique_ptr<CPDF_CrossRefAvail> m_pCrossRefAvail; diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index ba993c2e3c..73b4bcdc0c 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -69,7 +69,7 @@ class CPDF_Parser::TrailerData { // Info is optional. uint32_t info_obj_num = GetInfoObjNum(); - if (info_obj_num > 0) + if (info_obj_num != CPDF_Object::kInvalidObjNum) result->SetNewFor<CPDF_Reference>("Info", nullptr, GetInfoObjNum()); // Root is required. @@ -90,8 +90,8 @@ class CPDF_Parser::TrailerData { void Clear() { main_trailer_.reset(); - last_info_obj_num_ = 0; - last_root_obj_num_ = 0; + last_info_obj_num_ = CPDF_Object::kInvalidObjNum; + last_root_obj_num_ = CPDF_Object::kInvalidObjNum; } uint32_t GetInfoObjNum() const { @@ -120,8 +120,8 @@ class CPDF_Parser::TrailerData { } std::unique_ptr<CPDF_Dictionary> main_trailer_; - uint32_t last_info_obj_num_ = 0; - uint32_t last_root_obj_num_ = 0; + uint32_t last_info_obj_num_ = CPDF_Object::kInvalidObjNum; + uint32_t last_root_obj_num_ = CPDF_Object::kInvalidObjNum; }; CPDF_Parser::CPDF_Parser() @@ -286,9 +286,9 @@ CPDF_Parser::Error CPDF_Parser::StartParseInternal(CPDF_Document* pDocument) { if (!m_pDocument->GetRoot()) return FORMAT_ERROR; } - if (GetRootObjNum() == 0) { + if (GetRootObjNum() == CPDF_Object::kInvalidObjNum) { ReleaseEncryptHandler(); - if (!RebuildCrossRef() || GetRootObjNum() == 0) + if (!RebuildCrossRef() || GetRootObjNum() == CPDF_Object::kInvalidObjNum) return FORMAT_ERROR; eRet = SetEncryptHandler(); @@ -1389,9 +1389,9 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( return FORMAT_ERROR; } - if (GetRootObjNum() == 0) { + if (GetRootObjNum() == CPDF_Object::kInvalidObjNum) { ReleaseEncryptHandler(); - if (!RebuildCrossRef() || GetRootObjNum() == 0) + if (!RebuildCrossRef() || GetRootObjNum() == CPDF_Object::kInvalidObjNum) return FORMAT_ERROR; eRet = SetEncryptHandler(); |