| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 m_LastObjNum++; | 49 m_LastObjNum++; |
| 50 m_IndirectObjs[m_LastObjNum].release(); // TODO(tsepez): stop this leak. | 50 m_IndirectObjs[m_LastObjNum].release(); // TODO(tsepez): stop this leak. |
| 51 m_IndirectObjs[m_LastObjNum].reset(pObj); | 51 m_IndirectObjs[m_LastObjNum].reset(pObj); |
| 52 pObj->m_ObjNum = m_LastObjNum; | 52 pObj->m_ObjNum = m_LastObjNum; |
| 53 return m_LastObjNum; | 53 return m_LastObjNum; |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration( | 56 bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration( |
| 57 uint32_t objnum, | 57 uint32_t objnum, |
| 58 CPDF_Object* pObj) { | 58 CPDF_Object* pObj) { |
| 59 if (!objnum || !pObj) | 59 ASSERT(objnum); |
| 60 if (!pObj) |
| 60 return false; | 61 return false; |
| 61 | 62 |
| 62 CPDF_Object* pOldObj = GetIndirectObject(objnum); | 63 CPDF_Object* pOldObj = GetIndirectObject(objnum); |
| 63 if (pOldObj && pObj->GetGenNum() <= pOldObj->GetGenNum()) { | 64 if (pOldObj && pObj->GetGenNum() <= pOldObj->GetGenNum()) { |
| 64 delete pObj; | 65 delete pObj; |
| 65 return false; | 66 return false; |
| 66 } | 67 } |
| 67 pObj->m_ObjNum = objnum; | 68 pObj->m_ObjNum = objnum; |
| 68 m_IndirectObjs[objnum].reset(pObj); | 69 m_IndirectObjs[objnum].reset(pObj); |
| 69 m_LastObjNum = std::max(m_LastObjNum, objnum); | 70 m_LastObjNum = std::max(m_LastObjNum, objnum); |
| 70 return true; | 71 return true; |
| 71 } | 72 } |
| 72 | 73 |
| 73 void CPDF_IndirectObjectHolder::ReleaseIndirectObject(uint32_t objnum) { | 74 void CPDF_IndirectObjectHolder::ReleaseIndirectObject(uint32_t objnum) { |
| 74 CPDF_Object* pObj = GetIndirectObject(objnum); | 75 CPDF_Object* pObj = GetIndirectObject(objnum); |
| 75 if (!pObj || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) | 76 if (!pObj || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) |
| 76 return; | 77 return; |
| 77 | 78 |
| 78 m_IndirectObjs.erase(objnum); | 79 m_IndirectObjs.erase(objnum); |
| 79 } | 80 } |
| OLD | NEW |