summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-04 15:45:02 -0700
committerCommit bot <commit-bot@chromium.org>2016-11-04 15:45:03 -0700
commit1d08c50d1c20798001a1944e8a1fd76d09643ef1 (patch)
tree062d248591c5b201f00a50c09995e94c09794bc2
parentc5267c54ea32ade03bf10e6bb203e34e3fcbd77d (diff)
downloadpdfium-1d08c50d1c20798001a1944e8a1fd76d09643ef1.tar.xz
CHECK for re-addition of indirect objects
Review-Url: https://codereview.chromium.org/2471263005
-rw-r--r--core/fpdfapi/parser/cpdf_document_unittest.cpp3
-rw-r--r--core/fpdfapi/parser/cpdf_indirect_object_holder.cpp4
2 files changed, 2 insertions, 5 deletions
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index 71716a649e..16d0ade069 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -69,8 +69,7 @@ class CPDF_TestDocumentForPages : public CPDF_Document {
CPDF_Dictionary* pagesDict = CreatePageTreeNode(allPages, this, 7);
m_pOwnedRootDict.reset(new CPDF_Dictionary());
- m_pOwnedRootDict->SetReferenceFor("Pages", this,
- AddIndirectObject(pagesDict));
+ m_pOwnedRootDict->SetReferenceFor("Pages", this, pagesDict->GetObjNum());
m_pRootDict = m_pOwnedRootDict.get();
m_PageList.SetSize(7);
}
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
index d3204e04e5..720fe18606 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
@@ -43,9 +43,7 @@ CPDF_Object* CPDF_IndirectObjectHolder::ParseIndirectObject(uint32_t objnum) {
}
uint32_t CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) {
- if (pObj->m_ObjNum)
- return pObj->m_ObjNum;
-
+ CHECK(!pObj->m_ObjNum);
m_LastObjNum++;
m_IndirectObjs[m_LastObjNum].release(); // TODO(tsepez): stop this leak.
m_IndirectObjs[m_LastObjNum].reset(pObj);