summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_array.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-10-14 16:59:10 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-14 16:59:10 -0700
commit3ba098595ae56b64eacc0c25ab76b89a4d78d920 (patch)
tree5c4db47295ea64cdf236c32ef7d5af5b8e7af232 /core/fpdfapi/parser/cpdf_array.cpp
parent1d023881cd53485303c0fcc0b5878e700dc470fd (diff)
downloadpdfium-3ba098595ae56b64eacc0c25ab76b89a4d78d920.tar.xz
Update CPDF_IndirectObjectHolder APIs for unique objects.
Doing so highlights a few places where ownership is dubious. Add convenience functions to return an unowned reference to a newly-created indirect object. Review-Url: https://codereview.chromium.org/2419173002
Diffstat (limited to 'core/fpdfapi/parser/cpdf_array.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_array.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp
index 807f62d7f3..db3b18be3e 100644
--- a/core/fpdfapi/parser/cpdf_array.cpp
+++ b/core/fpdfapi/parser/cpdf_array.cpp
@@ -152,8 +152,9 @@ void CPDF_Array::ConvertToIndirectObjectAt(size_t i,
if (!m_Objects[i] || m_Objects[i]->IsReference())
return;
- uint32_t dwObjNum = pHolder->AddIndirectObject(m_Objects[i].release());
- m_Objects[i] = UniqueObject(new CPDF_Reference(pHolder, dwObjNum));
+ CPDF_Object* pUnowned = pHolder->AddIndirectObject(std::move(m_Objects[i]));
+ m_Objects[i] =
+ UniqueObject(new CPDF_Reference(pHolder, pUnowned->GetObjNum()));
}
void CPDF_Array::SetAt(size_t i, CPDF_Object* pObj) {
@@ -205,3 +206,8 @@ void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc,
uint32_t objnum) {
Add(new CPDF_Reference(pDoc, objnum));
}
+
+void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc,
+ const CPDF_Object* pObj) {
+ AddReference(pDoc, pObj->GetObjNum());
+}