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

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

Issue 2250533002: Fix stack overflow in object Clone() functions (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: change due to rebase Created 4 years, 4 months 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
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/fpdf_parser/include/cpdf_indirect_object_holder.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
11 11
12 CPDF_IndirectObjectHolder::CPDF_IndirectObjectHolder() : m_LastObjNum(0) {} 12 CPDF_IndirectObjectHolder::CPDF_IndirectObjectHolder() : m_LastObjNum(0) {}
13 13
14 CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() { 14 CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() {
15 for (const auto& pair : m_IndirectObjs) 15 for (const auto& pair : m_IndirectObjs)
16 pair.second->Destroy(); 16 pair.second->Release();
dsinclair 2016/08/18 14:04:31 I believe this should be Destroy(). The Release()
Wei Li 2016/08/18 22:02:30 You are right, done.
17 } 17 }
18 18
19 CPDF_Object* CPDF_IndirectObjectHolder::GetIndirectObject( 19 CPDF_Object* CPDF_IndirectObjectHolder::GetIndirectObject(
20 uint32_t objnum) const { 20 uint32_t objnum) const {
21 if (objnum == 0) 21 if (objnum == 0)
22 return nullptr; 22 return nullptr;
23 23
24 auto it = m_IndirectObjs.find(objnum); 24 auto it = m_IndirectObjs.find(objnum);
25 return it != m_IndirectObjs.end() ? it->second : nullptr; 25 return it != m_IndirectObjs.end() ? it->second : nullptr;
26 } 26 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return true; 80 return true;
81 } 81 }
82 82
83 void CPDF_IndirectObjectHolder::ReplaceIndirectObject(CPDF_Object* pObj) { 83 void CPDF_IndirectObjectHolder::ReplaceIndirectObject(CPDF_Object* pObj) {
84 m_LastObjNum = std::max(m_LastObjNum, pObj->m_ObjNum); 84 m_LastObjNum = std::max(m_LastObjNum, pObj->m_ObjNum);
85 if (m_IndirectObjs[pObj->m_ObjNum]) 85 if (m_IndirectObjs[pObj->m_ObjNum])
86 m_IndirectObjs[pObj->m_ObjNum]->Destroy(); 86 m_IndirectObjs[pObj->m_ObjNum]->Destroy();
87 87
88 m_IndirectObjs[pObj->m_ObjNum] = pObj; 88 m_IndirectObjs[pObj->m_ObjNum] = pObj;
89 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698