From e07edce5b253bc4f2bef6888c5b1cbf0b320a919 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 23 Aug 2016 20:14:27 -0700 Subject: Make indirect object holder private. This CL moves the m_IndirectObjs map to be private to the IndirectObjectHolder. Various bits of code have been updated to use the accessors to the map. This CL fixes the issue with the last time this landed by removing the objnum check from GetIndirectObject() which appears to have caused the crashes. Review-Url: https://codereview.chromium.org/2275703002 --- core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'core/fpdfapi/fpdf_edit') diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 9ad1d060cc..7ece85a602 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -1233,8 +1233,7 @@ int32_t CPDF_Creator::WriteOldIndirectObject(uint32_t objnum) { return 0; m_ObjectOffset[objnum] = m_Offset; - FX_BOOL bExistInMap = - pdfium::ContainsKey(m_pDocument->m_IndirectObjs, objnum); + FX_BOOL bExistInMap = !!m_pDocument->GetIndirectObject(objnum); const uint8_t object_type = m_pParser->GetObjectType(objnum); bool bObjStm = (object_type == 2) && m_pEncryptDict && !m_pXRefStream; if (m_pParser->IsVersionUpdated() || m_bSecurityChanged || bExistInMap || @@ -1320,15 +1319,15 @@ int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause) { int32_t index = (int32_t)(uintptr_t)m_Pos; while (index < iCount) { uint32_t objnum = m_NewObjNumArray.ElementAt(index); - auto it = m_pDocument->m_IndirectObjs.find(objnum); - if (it == m_pDocument->m_IndirectObjs.end()) { + CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum); + if (!pObj) { ++index; continue; } m_ObjectOffset[objnum] = m_Offset; - if (WriteIndirectObj(it->second)) { + if (WriteIndirectObj(pObj)) return -1; - } + index++; if (pPause && pPause->NeedToPauseNow()) { m_Pos = (FX_POSITION)(uintptr_t)index; @@ -1363,7 +1362,7 @@ void CPDF_Creator::InitOldObjNumOffsets() { void CPDF_Creator::InitNewObjNumOffsets() { FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; - for (const auto& pair : m_pDocument->m_IndirectObjs) { + for (const auto& pair : *m_pDocument) { const uint32_t objnum = pair.first; const CPDF_Object* pObj = pair.second; if (bIncremental || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) -- cgit v1.2.3