Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: core/fpdfapi/parser/cpdf_indirect_object_holder.cpp

Issue 2471263005: CHECK for re-addition of indirect objects (Closed)
Patch Set: Fix test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_document_unittest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" 7 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
8 8
9 #include "core/fpdfapi/parser/cpdf_object.h" 9 #include "core/fpdfapi/parser/cpdf_object.h"
10 #include "core/fpdfapi/parser/cpdf_parser.h" 10 #include "core/fpdfapi/parser/cpdf_parser.h"
(...skipping 25 matching lines...) Expand all
36 m_LastObjNum = std::max(m_LastObjNum, objnum); 36 m_LastObjNum = std::max(m_LastObjNum, objnum);
37 m_IndirectObjs[objnum].reset(pObj); 37 m_IndirectObjs[objnum].reset(pObj);
38 return pObj; 38 return pObj;
39 } 39 }
40 40
41 CPDF_Object* CPDF_IndirectObjectHolder::ParseIndirectObject(uint32_t objnum) { 41 CPDF_Object* CPDF_IndirectObjectHolder::ParseIndirectObject(uint32_t objnum) {
42 return nullptr; 42 return nullptr;
43 } 43 }
44 44
45 uint32_t CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) { 45 uint32_t CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) {
46 if (pObj->m_ObjNum) 46 CHECK(!pObj->m_ObjNum);
47 return pObj->m_ObjNum;
48
49 m_LastObjNum++; 47 m_LastObjNum++;
50 m_IndirectObjs[m_LastObjNum].release(); // TODO(tsepez): stop this leak. 48 m_IndirectObjs[m_LastObjNum].release(); // TODO(tsepez): stop this leak.
51 m_IndirectObjs[m_LastObjNum].reset(pObj); 49 m_IndirectObjs[m_LastObjNum].reset(pObj);
52 pObj->m_ObjNum = m_LastObjNum; 50 pObj->m_ObjNum = m_LastObjNum;
53 return m_LastObjNum; 51 return m_LastObjNum;
54 } 52 }
55 53
56 bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration( 54 bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration(
57 uint32_t objnum, 55 uint32_t objnum,
58 CPDF_Object* pObj) { 56 CPDF_Object* pObj) {
(...skipping 12 matching lines...) Expand all
71 return true; 69 return true;
72 } 70 }
73 71
74 void CPDF_IndirectObjectHolder::DeleteIndirectObject(uint32_t objnum) { 72 void CPDF_IndirectObjectHolder::DeleteIndirectObject(uint32_t objnum) {
75 CPDF_Object* pObj = GetIndirectObject(objnum); 73 CPDF_Object* pObj = GetIndirectObject(objnum);
76 if (!pObj || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) 74 if (!pObj || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum)
77 return; 75 return;
78 76
79 m_IndirectObjs.erase(objnum); 77 m_IndirectObjs.erase(objnum);
80 } 78 }
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_document_unittest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698