From 33fdebc3da676bff84d0fd0f69b9087c0c12dfeb Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 4 Nov 2016 11:38:40 -0700 Subject: Reland "Remove CPDF_Object::Release() in favor of direct delete" This reverts commit f0d5b6c35fa343108a3ab7a25bc2cc2b3cf105b3. Review-Url: https://codereview.chromium.org/2478303002 --- core/fpdfapi/parser/cpdf_data_avail.cpp | 61 +++++++++++++++------------------ 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'core/fpdfapi/parser/cpdf_data_avail.cpp') diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index a077ebb715..eadbf1e828 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -83,17 +83,12 @@ CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail, CPDF_DataAvail::~CPDF_DataAvail() { m_pHintTables.reset(); - if (m_pLinearized) - m_pLinearized->Release(); - - if (m_pRoot) - m_pRoot->Release(); - - if (m_pTrailer) - m_pTrailer->Release(); + delete m_pLinearized; + delete m_pRoot; + delete m_pTrailer; for (CPDF_Object* pObject : m_arrayAcroforms) - pObject->Release(); + delete pObject; } void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) { @@ -230,7 +225,7 @@ bool CPDF_DataAvail::CheckAcroFormSubObject(DownloadHints* pHints) { } for (CPDF_Object* pObject : m_arrayAcroforms) - pObject->Release(); + delete pObject; m_arrayAcroforms.clear(); return true; @@ -400,9 +395,7 @@ bool CPDF_DataAvail::CheckInfo(DownloadHints* pHints) { return false; } - if (pInfo) - pInfo->Release(); - + delete pInfo; m_docStatus = (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE); @@ -499,7 +492,7 @@ bool CPDF_DataAvail::CheckPage(DownloadHints* pHints) { } if (!pObj->IsDictionary()) { - pObj->Release(); + delete pObj; continue; } @@ -508,7 +501,7 @@ bool CPDF_DataAvail::CheckPage(DownloadHints* pHints) { m_PagesArray.push_back(pObj); continue; } - pObj->Release(); + delete pObj; } m_PageObjList.RemoveAll(); @@ -524,15 +517,15 @@ bool CPDF_DataAvail::CheckPage(DownloadHints* pHints) { continue; if (!GetPageKids(m_pCurrentParser, pPages)) { - pPages->Release(); + delete pPages; while (++i < iPages) - m_PagesArray[i]->Release(); + delete m_PagesArray[i]; m_PagesArray.clear(); m_docStatus = PDF_DATAAVAIL_ERROR; return false; } - pPages->Release(); + delete pPages; } m_PagesArray.clear(); @@ -587,12 +580,12 @@ bool CPDF_DataAvail::CheckPages(DownloadHints* pHints) { } if (!GetPageKids(m_pCurrentParser, pPages)) { - pPages->Release(); + delete pPages; m_docStatus = PDF_DATAAVAIL_ERROR; return false; } - pPages->Release(); + delete pPages; m_docStatus = PDF_DATAAVAIL_PAGE; return true; } @@ -763,7 +756,7 @@ bool CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) { std::unique_ptr pHintTables( new CPDF_HintTables(this, pDict)); - std::unique_ptr> pHintStream( + std::unique_ptr pHintStream( ParseIndirectObjectAt(szHintStart, 0)); CPDF_Stream* pStream = ToStream(pHintStream.get()); if (pStream && pHintTables->LoadHintStream(pStream)) @@ -951,11 +944,11 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(DownloadHints* pHints, if (pName->GetString() == "XRef") { m_Pos += m_parser.m_pSyntax->SavePos(); xref_offset = pObj->GetDict()->GetIntegerFor("Prev"); - pObj->Release(); + delete pObj; return 1; } } - pObj->Release(); + delete pObj; return -1; } pHints->AddSegment(m_Pos, req_size); @@ -1181,7 +1174,7 @@ bool CPDF_DataAvail::CheckTrailer(DownloadHints* pHints) { ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false)); m_syntaxParser.InitParser(file.get(), 0); - std::unique_ptr> pTrailer( + std::unique_ptr pTrailer( m_syntaxParser.GetObject(nullptr, 0, 0, true)); if (!pTrailer) { m_Pos += m_syntaxParser.SavePos(); @@ -1266,7 +1259,7 @@ bool CPDF_DataAvail::CheckArrayPageNode(uint32_t dwPageNo, CPDF_Array* pArray = pPages->AsArray(); if (!pArray) { - pPages->Release(); + delete pPages; m_docStatus = PDF_DATAAVAIL_ERROR; return false; } @@ -1281,7 +1274,7 @@ bool CPDF_DataAvail::CheckArrayPageNode(uint32_t dwPageNo, pPageNode->m_childNode.Add(pNode); pNode->m_dwPageNo = pKid->GetRefObjNum(); } - pPages->Release(); + delete pPages; return true; } @@ -1304,12 +1297,12 @@ bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo, if (pPage->IsArray()) { pPageNode->m_dwPageNo = dwPageNo; pPageNode->m_type = PDF_PAGENODE_ARRAY; - pPage->Release(); + delete pPage; return true; } if (!pPage->IsDictionary()) { - pPage->Release(); + delete pPage; m_docStatus = PDF_DATAAVAIL_ERROR; return false; } @@ -1350,11 +1343,11 @@ bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo, } else if (type == "Page") { pPageNode->m_type = PDF_PAGENODE_PAGE; } else { - pPage->Release(); + delete pPage; m_docStatus = PDF_DATAAVAIL_ERROR; return false; } - pPage->Release(); + delete pPage; return true; } @@ -1442,23 +1435,23 @@ bool CPDF_DataAvail::CheckPageCount(DownloadHints* pHints) { CPDF_Dictionary* pPagesDict = pPages->GetDict(); if (!pPagesDict) { - pPages->Release(); + delete pPages; m_docStatus = PDF_DATAAVAIL_ERROR; return false; } if (!pPagesDict->KeyExist("Kids")) { - pPages->Release(); + delete pPages; return true; } int count = pPagesDict->GetIntegerFor("Count"); if (count > 0) { - pPages->Release(); + delete pPages; return true; } - pPages->Release(); + delete pPages; return false; } -- cgit v1.2.3