summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/parser/cpdf_array.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_array.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp
index 4000bbc980..e118fd66e6 100644
--- a/core/fpdfapi/parser/cpdf_array.cpp
+++ b/core/fpdfapi/parser/cpdf_array.cpp
@@ -24,7 +24,7 @@ CPDF_Array::~CPDF_Array() {
m_ObjNum = kInvalidObjNum;
for (auto& it : m_Objects) {
if (it && it->GetObjNum() != kInvalidObjNum)
- delete it;
+ it->Release();
}
}
@@ -139,9 +139,10 @@ void CPDF_Array::RemoveAt(size_t i, size_t nCount) {
if (nCount <= 0 || nCount > m_Objects.size() - i)
return;
- for (size_t j = 0; j < nCount; ++j)
- delete m_Objects[i + j];
-
+ for (size_t j = 0; j < nCount; ++j) {
+ if (CPDF_Object* p = m_Objects[i + j])
+ p->Release();
+ }
m_Objects.erase(m_Objects.begin() + i, m_Objects.begin() + i + nCount);
}
@@ -165,7 +166,9 @@ void CPDF_Array::SetAt(size_t i, CPDF_Object* pObj) {
ASSERT(false);
return;
}
- delete m_Objects[i];
+ if (CPDF_Object* pOld = m_Objects[i])
+ pOld->Release();
+
m_Objects[i] = pObj;
}