From 1d08c50d1c20798001a1944e8a1fd76d09643ef1 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 4 Nov 2016 15:45:02 -0700 Subject: CHECK for re-addition of indirect objects Review-Url: https://codereview.chromium.org/2471263005 --- core/fpdfapi/parser/cpdf_document_unittest.cpp | 3 +-- core/fpdfapi/parser/cpdf_indirect_object_holder.cpp | 4 +--- 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); -- cgit v1.2.3