From 260f5fbf3553a96fa49b029cc050220039c30e2a Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 17 Aug 2016 12:45:26 -0700 Subject: 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. Review-Url: https://codereview.chromium.org/2253723002 --- core/fpdfapi/fpdf_parser/cpdf_parser.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'core/fpdfapi/fpdf_parser/cpdf_parser.cpp') diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp index b2f1a4be3f..ffd3f79a62 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp @@ -267,7 +267,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() { if (CPDF_Dictionary* pEncryptDict = pEncryptObj->AsDictionary()) { SetEncryptDictionary(pEncryptDict); } else if (CPDF_Reference* pRef = pEncryptObj->AsReference()) { - pEncryptObj = m_pDocument->GetIndirectObject(pRef->GetRefObjNum()); + pEncryptObj = m_pDocument->GetOrParseIndirectObject(pRef->GetRefObjNum()); if (pEncryptObj) SetEncryptDictionary(pEncryptObj->GetDict()); } @@ -982,12 +982,16 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { if (m_pDocument) { CPDF_Dictionary* pRootDict = m_pDocument->GetRoot(); if (pRootDict && pRootDict->GetObjNum() == pObject->m_ObjNum) { + // If |pObject| has an objnum assigned then this will leak as Release() + // will early exit. if (pObject->IsStream()) pObject->Release(); return FALSE; } - if (!m_pDocument->InsertIndirectObject(pObject->m_ObjNum, pObject)) + if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration(pObject->m_ObjNum, + pObject)) { return FALSE; + } } CPDF_Stream* pStream = pObject->AsStream(); @@ -1230,7 +1234,8 @@ CPDF_StreamAcc* CPDF_Parser::GetObjectStream(uint32_t objnum) { if (!m_pDocument) return nullptr; - const CPDF_Stream* pStream = ToStream(m_pDocument->GetIndirectObject(objnum)); + const CPDF_Stream* pStream = + ToStream(m_pDocument->GetOrParseIndirectObject(objnum)); if (!pStream) return nullptr; -- cgit v1.2.3