summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_edit
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-08-22 10:24:43 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-22 10:24:43 -0700
commit8d6c929d2605dc568beb73aab2c585622947fee2 (patch)
tree9144254a1bcd59bad80dd4d06d17a96977966c47 /core/fpdfapi/fpdf_edit
parenta4f46c57f4e4217f50e98ac74b360793284ee73f (diff)
downloadpdfium-8d6c929d2605dc568beb73aab2c585622947fee2.tar.xz
Revert of Move parser pointer to CPDF_Document (patchset #6 id:100001 of https://codereview.chromium.org/2253723002/ )
Reason for revert: Causing asan issues. See crbug.com/639451. Original issue's description: > Move parser pointer to CPDF_Document > > The CPDF_IndirectObjectHolder has two subclasses, CPDF_Document and > CFDF_Document. The CPDF document requires the parser and the CFDF document > does not. This cl moves the parser pointer up to CPDF_Document. > > Committed: https://pdfium.googlesource.com/pdfium/+/260f5fbf3553a96fa49b029cc050220039c30e2a TBR=tsepez@chromium.org,thestig@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. Review-Url: https://codereview.chromium.org/2266033002
Diffstat (limited to 'core/fpdfapi/fpdf_edit')
-rw-r--r--core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index eb3f156b2d..c20a483764 100644
--- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -1233,12 +1233,13 @@ int32_t CPDF_Creator::WriteOldIndirectObject(uint32_t objnum) {
return 0;
m_ObjectOffset[objnum] = m_Offset;
- FX_BOOL bExistInMap = !!m_pDocument->GetIndirectObject(objnum);
+ FX_BOOL bExistInMap =
+ pdfium::ContainsKey(m_pDocument->m_IndirectObjs, 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 ||
bObjStm) {
- CPDF_Object* pObj = m_pDocument->GetOrParseIndirectObject(objnum);
+ CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum);
if (!pObj) {
m_ObjectOffset[objnum] = 0;
return 0;
@@ -1319,13 +1320,13 @@ 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);
- CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum);
- if (!pObj) {
+ auto it = m_pDocument->m_IndirectObjs.find(objnum);
+ if (it == m_pDocument->m_IndirectObjs.end()) {
++index;
continue;
}
m_ObjectOffset[objnum] = m_Offset;
- if (WriteIndirectObj(pObj)) {
+ if (WriteIndirectObj(it->second)) {
return -1;
}
index++;
@@ -1362,7 +1363,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) {
+ for (const auto& pair : m_pDocument->m_IndirectObjs) {
const uint32_t objnum = pair.first;
const CPDF_Object* pObj = pair.second;
if (bIncremental || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum)
@@ -1702,7 +1703,7 @@ int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) {
return -1;
}
} else {
- if (m_File.AppendDWord(m_pDocument->GetLastObjNum() + 1) < 0) {
+ if (m_File.AppendDWord(m_pDocument->m_LastObjNum + 1) < 0) {
return -1;
}
if (m_File.AppendString(" 0 obj <<") < 0) {