summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/parser/cpdf_indirect_object_holder.cpp10
-rw-r--r--core/fpdfapi/parser/cpdf_object.h22
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp4
3 files changed, 15 insertions, 21 deletions
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
index 2a57411368..42e312ca64 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
@@ -52,7 +52,7 @@ CPDF_Object* CPDF_IndirectObjectHolder::GetOrParseIndirectObject(
return nullptr;
}
- pNewObj->m_ObjNum = objnum;
+ pNewObj->SetObjNum(objnum);
m_LastObjNum = std::max(m_LastObjNum, objnum);
insert_result.first->second = std::move(pNewObj);
return insert_result.first->second.get();
@@ -65,8 +65,8 @@ std::unique_ptr<CPDF_Object> CPDF_IndirectObjectHolder::ParseIndirectObject(
CPDF_Object* CPDF_IndirectObjectHolder::AddIndirectObject(
std::unique_ptr<CPDF_Object> pObj) {
- CHECK(!pObj->m_ObjNum);
- pObj->m_ObjNum = ++m_LastObjNum;
+ CHECK(!pObj->GetObjNum());
+ pObj->SetObjNum(++m_LastObjNum);
auto& obj_holder = m_IndirectObjs[m_LastObjNum];
if (obj_holder)
@@ -84,13 +84,11 @@ bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration(
return false;
auto& obj_holder = m_IndirectObjs[objnum];
-
const CPDF_Object* old_object = FilterInvalidObjNum(obj_holder.get());
-
if (old_object && pObj->GetGenNum() <= old_object->GetGenNum())
return false;
- pObj->m_ObjNum = objnum;
+ pObj->SetObjNum(objnum);
if (obj_holder)
m_OrphanObjs.push_back(std::move(obj_holder));
diff --git a/core/fpdfapi/parser/cpdf_object.h b/core/fpdfapi/parser/cpdf_object.h
index 4d4279f98a..7a14492d70 100644
--- a/core/fpdfapi/parser/cpdf_object.h
+++ b/core/fpdfapi/parser/cpdf_object.h
@@ -44,7 +44,9 @@ class CPDF_Object {
virtual Type GetType() const = 0;
uint32_t GetObjNum() const { return m_ObjNum; }
+ void SetObjNum(uint32_t objnum) { m_ObjNum = objnum; }
uint32_t GetGenNum() const { return m_GenNum; }
+ void SetGenNum(uint32_t gennum) { m_GenNum = gennum; }
bool IsInline() const { return m_ObjNum == 0; }
// Create a deep copy of the object.
@@ -92,18 +94,6 @@ class CPDF_Object {
virtual bool WriteTo(IFX_ArchiveStream* archive) const = 0;
- protected:
- friend class CPDF_Array;
- friend class CPDF_Dictionary;
- friend class CPDF_IndirectObjectHolder;
- friend class CPDF_SyntaxParser;
- friend class CPDF_Reference;
- friend class CPDF_Stream;
-
- CPDF_Object() : m_ObjNum(0), m_GenNum(0) {}
-
- std::unique_ptr<CPDF_Object> CloneObjectNonCyclic(bool bDirect) const;
-
// Create a deep copy of the object with the option to either
// copy a reference object or directly copy the object it refers to
// when |bDirect| is true.
@@ -114,11 +104,17 @@ class CPDF_Object {
bool bDirect,
std::set<const CPDF_Object*>* pVisited) const;
+ protected:
+ CPDF_Object() : m_ObjNum(0), m_GenNum(0) {}
+
+ std::unique_ptr<CPDF_Object> CloneObjectNonCyclic(bool bDirect) const;
+
uint32_t m_ObjNum;
- uint32_t m_GenNum;
private:
CPDF_Object(const CPDF_Object& src) {}
+
+ uint32_t m_GenNum;
};
template <typename T>
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index 0c483ac107..f0ea5ac5b0 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -500,8 +500,8 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetIndirectObject(
std::unique_ptr<CPDF_Object> pObj =
GetObjectBodyInternal(pObjList, parse_type);
if (pObj) {
- pObj->m_ObjNum = parser_objnum;
- pObj->m_GenNum = parser_gennum;
+ pObj->SetObjNum(parser_objnum);
+ pObj->SetGenNum(parser_gennum);
}
return GetValidator()->has_read_problems() ? nullptr : std::move(pObj);