Index: core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp |
diff --git a/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp b/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp |
index dc639feb1a4b28915b5916d23e4fb68523e82c50..800e34b3d1eb62f3a1de4c4fc27c6a5727bc702a 100644 |
--- a/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp |
+++ b/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp |
@@ -11,15 +11,12 @@ |
CPDF_IndirectObjectHolder::CPDF_IndirectObjectHolder() : m_LastObjNum(0) {} |
-CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() { |
- for (const auto& pair : m_IndirectObjs) |
- delete pair.second; |
-} |
+CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() {} |
CPDF_Object* CPDF_IndirectObjectHolder::GetIndirectObject( |
uint32_t objnum) const { |
auto it = m_IndirectObjs.find(objnum); |
- return it != m_IndirectObjs.end() ? it->second : nullptr; |
+ return it != m_IndirectObjs.end() ? it->second.get() : nullptr; |
} |
CPDF_Object* CPDF_IndirectObjectHolder::GetOrParseIndirectObject( |
@@ -37,10 +34,7 @@ CPDF_Object* CPDF_IndirectObjectHolder::GetOrParseIndirectObject( |
pObj->m_ObjNum = objnum; |
m_LastObjNum = std::max(m_LastObjNum, objnum); |
- if (m_IndirectObjs[objnum]) |
- delete m_IndirectObjs[objnum]; |
- |
- m_IndirectObjs[objnum] = pObj; |
+ m_IndirectObjs[objnum].reset(pObj); |
return pObj; |
} |
@@ -53,7 +47,7 @@ uint32_t CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) { |
return pObj->m_ObjNum; |
m_LastObjNum++; |
- m_IndirectObjs[m_LastObjNum] = pObj; |
+ m_IndirectObjs[m_LastObjNum].reset(pObj); |
pObj->m_ObjNum = m_LastObjNum; |
return m_LastObjNum; |
} |
@@ -65,15 +59,12 @@ bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration( |
return false; |
CPDF_Object* pOldObj = GetIndirectObject(objnum); |
- if (pOldObj) { |
- if (pObj->GetGenNum() <= pOldObj->GetGenNum()) { |
- delete pObj; |
- return false; |
- } |
- delete pOldObj; |
+ if (pOldObj && pObj->GetGenNum() <= pOldObj->GetGenNum()) { |
+ delete pObj; |
+ return false; |
} |
pObj->m_ObjNum = objnum; |
- m_IndirectObjs[objnum] = pObj; |
+ m_IndirectObjs[objnum].reset(pObj); |
m_LastObjNum = std::max(m_LastObjNum, objnum); |
return true; |
} |
@@ -83,6 +74,5 @@ void CPDF_IndirectObjectHolder::ReleaseIndirectObject(uint32_t objnum) { |
if (!pObj || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) |
return; |
- delete pObj; |
m_IndirectObjs.erase(objnum); |
} |