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

Unified Diff: core/fpdfapi/parser/cpdf_data_avail.cpp

Issue 2478253002: Revert of Remove CPDF_Object::Release() in favor of direct delete (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_array_unittest.cpp ('k') | core/fpdfapi/parser/cpdf_dictionary.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: 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 eadbf1e8282c144c0e5f72c4f3783e18668bd033..a077ebb7150fb386903b2566a4a364491e38e23c 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -83,12 +83,17 @@
CPDF_DataAvail::~CPDF_DataAvail() {
m_pHintTables.reset();
- delete m_pLinearized;
- delete m_pRoot;
- delete m_pTrailer;
+ if (m_pLinearized)
+ m_pLinearized->Release();
+
+ if (m_pRoot)
+ m_pRoot->Release();
+
+ if (m_pTrailer)
+ m_pTrailer->Release();
for (CPDF_Object* pObject : m_arrayAcroforms)
- delete pObject;
+ pObject->Release();
}
void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) {
@@ -225,7 +230,7 @@
}
for (CPDF_Object* pObject : m_arrayAcroforms)
- delete pObject;
+ pObject->Release();
m_arrayAcroforms.clear();
return true;
@@ -395,7 +400,9 @@
return false;
}
- delete pInfo;
+ if (pInfo)
+ pInfo->Release();
+
m_docStatus =
(m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE);
@@ -492,7 +499,7 @@
}
if (!pObj->IsDictionary()) {
- delete pObj;
+ pObj->Release();
continue;
}
@@ -501,7 +508,7 @@
m_PagesArray.push_back(pObj);
continue;
}
- delete pObj;
+ pObj->Release();
}
m_PageObjList.RemoveAll();
@@ -517,15 +524,15 @@
continue;
if (!GetPageKids(m_pCurrentParser, pPages)) {
- delete pPages;
+ pPages->Release();
while (++i < iPages)
- delete m_PagesArray[i];
+ m_PagesArray[i]->Release();
m_PagesArray.clear();
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
- delete pPages;
+ pPages->Release();
}
m_PagesArray.clear();
@@ -580,12 +587,12 @@
}
if (!GetPageKids(m_pCurrentParser, pPages)) {
- delete pPages;
- m_docStatus = PDF_DATAAVAIL_ERROR;
- return false;
- }
-
- delete pPages;
+ pPages->Release();
+ m_docStatus = PDF_DATAAVAIL_ERROR;
+ return false;
+ }
+
+ pPages->Release();
m_docStatus = PDF_DATAAVAIL_PAGE;
return true;
}
@@ -756,7 +763,7 @@
std::unique_ptr<CPDF_HintTables> pHintTables(
new CPDF_HintTables(this, pDict));
- std::unique_ptr<CPDF_Object> pHintStream(
+ std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pHintStream(
ParseIndirectObjectAt(szHintStart, 0));
CPDF_Stream* pStream = ToStream(pHintStream.get());
if (pStream && pHintTables->LoadHintStream(pStream))
@@ -944,11 +951,11 @@
if (pName->GetString() == "XRef") {
m_Pos += m_parser.m_pSyntax->SavePos();
xref_offset = pObj->GetDict()->GetIntegerFor("Prev");
- delete pObj;
+ pObj->Release();
return 1;
}
}
- delete pObj;
+ pObj->Release();
return -1;
}
pHints->AddSegment(m_Pos, req_size);
@@ -1174,7 +1181,7 @@
ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false));
m_syntaxParser.InitParser(file.get(), 0);
- std::unique_ptr<CPDF_Object> pTrailer(
+ std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pTrailer(
m_syntaxParser.GetObject(nullptr, 0, 0, true));
if (!pTrailer) {
m_Pos += m_syntaxParser.SavePos();
@@ -1259,7 +1266,7 @@
CPDF_Array* pArray = pPages->AsArray();
if (!pArray) {
- delete pPages;
+ pPages->Release();
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
@@ -1274,7 +1281,7 @@
pPageNode->m_childNode.Add(pNode);
pNode->m_dwPageNo = pKid->GetRefObjNum();
}
- delete pPages;
+ pPages->Release();
return true;
}
@@ -1297,12 +1304,12 @@
if (pPage->IsArray()) {
pPageNode->m_dwPageNo = dwPageNo;
pPageNode->m_type = PDF_PAGENODE_ARRAY;
- delete pPage;
+ pPage->Release();
return true;
}
if (!pPage->IsDictionary()) {
- delete pPage;
+ pPage->Release();
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
@@ -1343,11 +1350,11 @@
} else if (type == "Page") {
pPageNode->m_type = PDF_PAGENODE_PAGE;
} else {
- delete pPage;
- m_docStatus = PDF_DATAAVAIL_ERROR;
- return false;
- }
- delete pPage;
+ pPage->Release();
+ m_docStatus = PDF_DATAAVAIL_ERROR;
+ return false;
+ }
+ pPage->Release();
return true;
}
@@ -1435,23 +1442,23 @@
CPDF_Dictionary* pPagesDict = pPages->GetDict();
if (!pPagesDict) {
- delete pPages;
+ pPages->Release();
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
if (!pPagesDict->KeyExist("Kids")) {
- delete pPages;
+ pPages->Release();
return true;
}
int count = pPagesDict->GetIntegerFor("Count");
if (count > 0) {
- delete pPages;
- return true;
- }
-
- delete pPages;
+ pPages->Release();
+ return true;
+ }
+
+ pPages->Release();
return false;
}
« no previous file with comments | « core/fpdfapi/parser/cpdf_array_unittest.cpp ('k') | core/fpdfapi/parser/cpdf_dictionary.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698