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

Side by Side Diff: core/fpdfapi/parser/cpdf_data_avail.cpp

Issue 2384883003: Remove CPDF_Object::Release() in favor of direct delete (Closed)
Patch Set: rebase 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/parser/cpdf_data_avail.h" 7 #include "core/fpdfapi/parser/cpdf_data_avail.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 m_docStatus = PDF_DATAAVAIL_HEADER; 76 m_docStatus = PDF_DATAAVAIL_HEADER;
77 m_parser.m_bOwnFileRead = false; 77 m_parser.m_bOwnFileRead = false;
78 m_bTotalLoadPageTree = false; 78 m_bTotalLoadPageTree = false;
79 m_bCurPageDictLoadOK = false; 79 m_bCurPageDictLoadOK = false;
80 m_bLinearedDataOK = false; 80 m_bLinearedDataOK = false;
81 m_bSupportHintTable = bSupportHintTable; 81 m_bSupportHintTable = bSupportHintTable;
82 } 82 }
83 83
84 CPDF_DataAvail::~CPDF_DataAvail() { 84 CPDF_DataAvail::~CPDF_DataAvail() {
85 m_pHintTables.reset(); 85 m_pHintTables.reset();
86 if (m_pLinearized) 86 delete m_pLinearized;
87 m_pLinearized->Release(); 87 delete m_pRoot;
88 88 delete m_pTrailer;
89 if (m_pRoot)
90 m_pRoot->Release();
91
92 if (m_pTrailer)
93 m_pTrailer->Release();
94 89
95 for (CPDF_Object* pObject : m_arrayAcroforms) 90 for (CPDF_Object* pObject : m_arrayAcroforms)
96 pObject->Release(); 91 delete pObject;
97 } 92 }
98 93
99 void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) { 94 void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) {
100 m_pDocument = pDoc; 95 m_pDocument = pDoc;
101 } 96 }
102 97
103 uint32_t CPDF_DataAvail::GetObjectSize(uint32_t objnum, FX_FILESIZE& offset) { 98 uint32_t CPDF_DataAvail::GetObjectSize(uint32_t objnum, FX_FILESIZE& offset) {
104 CPDF_Parser* pParser = m_pDocument->GetParser(); 99 CPDF_Parser* pParser = m_pDocument->GetParser();
105 if (!pParser || !pParser->IsValidObjectNumber(objnum)) 100 if (!pParser || !pParser->IsValidObjectNumber(objnum))
106 return 0; 101 return 0;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return true; 218 return true;
224 } 219 }
225 220
226 std::vector<CPDF_Object*> new_objs_array; 221 std::vector<CPDF_Object*> new_objs_array;
227 if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) { 222 if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) {
228 m_objs_array = new_objs_array; 223 m_objs_array = new_objs_array;
229 return false; 224 return false;
230 } 225 }
231 226
232 for (CPDF_Object* pObject : m_arrayAcroforms) 227 for (CPDF_Object* pObject : m_arrayAcroforms)
233 pObject->Release(); 228 delete pObject;
234 229
235 m_arrayAcroforms.clear(); 230 m_arrayAcroforms.clear();
236 return true; 231 return true;
237 } 232 }
238 233
239 bool CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) { 234 bool CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) {
240 bool bExist = false; 235 bool bExist = false;
241 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist); 236 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist);
242 if (!bExist) { 237 if (!bExist) {
243 m_docStatus = PDF_DATAAVAIL_PAGETREE; 238 m_docStatus = PDF_DATAAVAIL_PAGETREE;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 if (m_docStatus == PDF_DATAAVAIL_ERROR) { 388 if (m_docStatus == PDF_DATAAVAIL_ERROR) {
394 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; 389 m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
395 return true; 390 return true;
396 } 391 }
397 392
398 if (m_Pos == m_dwFileLen) 393 if (m_Pos == m_dwFileLen)
399 m_docStatus = PDF_DATAAVAIL_ERROR; 394 m_docStatus = PDF_DATAAVAIL_ERROR;
400 return false; 395 return false;
401 } 396 }
402 397
403 if (pInfo) 398 delete pInfo;
404 pInfo->Release();
405
406 m_docStatus = 399 m_docStatus =
407 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE); 400 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE);
408 401
409 return true; 402 return true;
410 } 403 }
411 404
412 bool CPDF_DataAvail::CheckRoot(DownloadHints* pHints) { 405 bool CPDF_DataAvail::CheckRoot(DownloadHints* pHints) {
413 bool bExist = false; 406 bool bExist = false;
414 m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist); 407 m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist);
415 if (!bExist) { 408 if (!bExist) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 485
493 CPDF_Array* pArray = ToArray(pObj); 486 CPDF_Array* pArray = ToArray(pObj);
494 if (pArray) { 487 if (pArray) {
495 for (CPDF_Object* pArrayObj : *pArray) { 488 for (CPDF_Object* pArrayObj : *pArray) {
496 if (CPDF_Reference* pRef = ToReference(pArrayObj)) 489 if (CPDF_Reference* pRef = ToReference(pArrayObj))
497 UnavailObjList.Add(pRef->GetRefObjNum()); 490 UnavailObjList.Add(pRef->GetRefObjNum());
498 } 491 }
499 } 492 }
500 493
501 if (!pObj->IsDictionary()) { 494 if (!pObj->IsDictionary()) {
502 pObj->Release(); 495 delete pObj;
503 continue; 496 continue;
504 } 497 }
505 498
506 CFX_ByteString type = pObj->GetDict()->GetStringFor("Type"); 499 CFX_ByteString type = pObj->GetDict()->GetStringFor("Type");
507 if (type == "Pages") { 500 if (type == "Pages") {
508 m_PagesArray.push_back(pObj); 501 m_PagesArray.push_back(pObj);
509 continue; 502 continue;
510 } 503 }
511 pObj->Release(); 504 delete pObj;
512 } 505 }
513 506
514 m_PageObjList.RemoveAll(); 507 m_PageObjList.RemoveAll();
515 if (UnavailObjList.GetSize()) { 508 if (UnavailObjList.GetSize()) {
516 m_PageObjList.Append(UnavailObjList); 509 m_PageObjList.Append(UnavailObjList);
517 return false; 510 return false;
518 } 511 }
519 512
520 uint32_t iPages = m_PagesArray.size(); 513 uint32_t iPages = m_PagesArray.size();
521 for (uint32_t i = 0; i < iPages; i++) { 514 for (uint32_t i = 0; i < iPages; i++) {
522 CPDF_Object* pPages = m_PagesArray[i]; 515 CPDF_Object* pPages = m_PagesArray[i];
523 if (!pPages) 516 if (!pPages)
524 continue; 517 continue;
525 518
526 if (!GetPageKids(m_pCurrentParser, pPages)) { 519 if (!GetPageKids(m_pCurrentParser, pPages)) {
527 pPages->Release(); 520 delete pPages;
528 while (++i < iPages) 521 while (++i < iPages)
529 m_PagesArray[i]->Release(); 522 delete m_PagesArray[i];
530 523
531 m_PagesArray.clear(); 524 m_PagesArray.clear();
532 m_docStatus = PDF_DATAAVAIL_ERROR; 525 m_docStatus = PDF_DATAAVAIL_ERROR;
533 return false; 526 return false;
534 } 527 }
535 pPages->Release(); 528 delete pPages;
536 } 529 }
537 530
538 m_PagesArray.clear(); 531 m_PagesArray.clear();
539 if (!m_PageObjList.GetSize()) 532 if (!m_PageObjList.GetSize())
540 m_docStatus = PDF_DATAAVAIL_DONE; 533 m_docStatus = PDF_DATAAVAIL_DONE;
541 return true; 534 return true;
542 } 535 }
543 536
544 bool CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { 537 bool CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) {
545 if (!pParser) { 538 if (!pParser) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 573
581 if (!pPages) { 574 if (!pPages) {
582 if (m_docStatus == PDF_DATAAVAIL_ERROR) { 575 if (m_docStatus == PDF_DATAAVAIL_ERROR) {
583 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; 576 m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
584 return true; 577 return true;
585 } 578 }
586 return false; 579 return false;
587 } 580 }
588 581
589 if (!GetPageKids(m_pCurrentParser, pPages)) { 582 if (!GetPageKids(m_pCurrentParser, pPages)) {
590 pPages->Release(); 583 delete pPages;
591 m_docStatus = PDF_DATAAVAIL_ERROR; 584 m_docStatus = PDF_DATAAVAIL_ERROR;
592 return false; 585 return false;
593 } 586 }
594 587
595 pPages->Release(); 588 delete pPages;
596 m_docStatus = PDF_DATAAVAIL_PAGE; 589 m_docStatus = PDF_DATAAVAIL_PAGE;
597 return true; 590 return true;
598 } 591 }
599 592
600 bool CPDF_DataAvail::CheckHeader(DownloadHints* pHints) { 593 bool CPDF_DataAvail::CheckHeader(DownloadHints* pHints) {
601 ASSERT(m_dwFileLen >= 0); 594 ASSERT(m_dwFileLen >= 0);
602 const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U); 595 const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U);
603 596
604 if (m_pFileAvail->IsDataAvail(0, kReqSize)) { 597 if (m_pFileAvail->IsDataAvail(0, kReqSize)) {
605 uint8_t buffer[1024]; 598 uint8_t buffer[1024];
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 return false; 749 return false;
757 } 750 }
758 751
759 if (!IsDataAvail(szHintStart, szHintLength, pHints)) 752 if (!IsDataAvail(szHintStart, szHintLength, pHints))
760 return false; 753 return false;
761 754
762 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); 755 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset);
763 756
764 std::unique_ptr<CPDF_HintTables> pHintTables( 757 std::unique_ptr<CPDF_HintTables> pHintTables(
765 new CPDF_HintTables(this, pDict)); 758 new CPDF_HintTables(this, pDict));
766 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pHintStream( 759 std::unique_ptr<CPDF_Object> pHintStream(
767 ParseIndirectObjectAt(szHintStart, 0)); 760 ParseIndirectObjectAt(szHintStart, 0));
768 CPDF_Stream* pStream = ToStream(pHintStream.get()); 761 CPDF_Stream* pStream = ToStream(pHintStream.get());
769 if (pStream && pHintTables->LoadHintStream(pStream)) 762 if (pStream && pHintTables->LoadHintStream(pStream))
770 m_pHintTables = std::move(pHintTables); 763 m_pHintTables = std::move(pHintTables);
771 764
772 m_docStatus = PDF_DATAAVAIL_DONE; 765 m_docStatus = PDF_DATAAVAIL_DONE;
773 return true; 766 return true;
774 } 767 }
775 768
776 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt( 769 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt(
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 m_Pos += m_parser.m_pSyntax->SavePos(); 937 m_Pos += m_parser.m_pSyntax->SavePos();
945 return 0; 938 return 0;
946 } 939 }
947 940
948 CPDF_Dictionary* pDict = pObj->GetDict(); 941 CPDF_Dictionary* pDict = pObj->GetDict();
949 CPDF_Name* pName = ToName(pDict ? pDict->GetObjectFor("Type") : nullptr); 942 CPDF_Name* pName = ToName(pDict ? pDict->GetObjectFor("Type") : nullptr);
950 if (pName) { 943 if (pName) {
951 if (pName->GetString() == "XRef") { 944 if (pName->GetString() == "XRef") {
952 m_Pos += m_parser.m_pSyntax->SavePos(); 945 m_Pos += m_parser.m_pSyntax->SavePos();
953 xref_offset = pObj->GetDict()->GetIntegerFor("Prev"); 946 xref_offset = pObj->GetDict()->GetIntegerFor("Prev");
954 pObj->Release(); 947 delete pObj;
955 return 1; 948 return 1;
956 } 949 }
957 } 950 }
958 pObj->Release(); 951 delete pObj;
959 return -1; 952 return -1;
960 } 953 }
961 pHints->AddSegment(m_Pos, req_size); 954 pHints->AddSegment(m_Pos, req_size);
962 return 0; 955 return 0;
963 } 956 }
964 957
965 void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) { 958 void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) {
966 m_Pos = dwOffset; 959 m_Pos = dwOffset;
967 } 960 }
968 961
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 m_docStatus = PDF_DATAAVAIL_ERROR; 1167 m_docStatus = PDF_DATAAVAIL_ERROR;
1175 return false; 1168 return false;
1176 } 1169 }
1177 1170
1178 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) 1171 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize))
1179 return false; 1172 return false;
1180 1173
1181 ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false)); 1174 ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false));
1182 m_syntaxParser.InitParser(file.get(), 0); 1175 m_syntaxParser.InitParser(file.get(), 0);
1183 1176
1184 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pTrailer( 1177 std::unique_ptr<CPDF_Object> pTrailer(
1185 m_syntaxParser.GetObject(nullptr, 0, 0, true)); 1178 m_syntaxParser.GetObject(nullptr, 0, 0, true));
1186 if (!pTrailer) { 1179 if (!pTrailer) {
1187 m_Pos += m_syntaxParser.SavePos(); 1180 m_Pos += m_syntaxParser.SavePos();
1188 pHints->AddSegment(m_Pos, iTrailerSize); 1181 pHints->AddSegment(m_Pos, iTrailerSize);
1189 return false; 1182 return false;
1190 } 1183 }
1191 1184
1192 if (!pTrailer->IsDictionary()) 1185 if (!pTrailer->IsDictionary())
1193 return false; 1186 return false;
1194 1187
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 if (!pPages) { 1252 if (!pPages) {
1260 if (m_docStatus == PDF_DATAAVAIL_ERROR) { 1253 if (m_docStatus == PDF_DATAAVAIL_ERROR) {
1261 m_docStatus = PDF_DATAAVAIL_ERROR; 1254 m_docStatus = PDF_DATAAVAIL_ERROR;
1262 return false; 1255 return false;
1263 } 1256 }
1264 return false; 1257 return false;
1265 } 1258 }
1266 1259
1267 CPDF_Array* pArray = pPages->AsArray(); 1260 CPDF_Array* pArray = pPages->AsArray();
1268 if (!pArray) { 1261 if (!pArray) {
1269 pPages->Release(); 1262 delete pPages;
1270 m_docStatus = PDF_DATAAVAIL_ERROR; 1263 m_docStatus = PDF_DATAAVAIL_ERROR;
1271 return false; 1264 return false;
1272 } 1265 }
1273 1266
1274 pPageNode->m_type = PDF_PAGENODE_PAGES; 1267 pPageNode->m_type = PDF_PAGENODE_PAGES;
1275 for (size_t i = 0; i < pArray->GetCount(); ++i) { 1268 for (size_t i = 0; i < pArray->GetCount(); ++i) {
1276 CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i)); 1269 CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i));
1277 if (!pKid) 1270 if (!pKid)
1278 continue; 1271 continue;
1279 1272
1280 PageNode* pNode = new PageNode(); 1273 PageNode* pNode = new PageNode();
1281 pPageNode->m_childNode.Add(pNode); 1274 pPageNode->m_childNode.Add(pNode);
1282 pNode->m_dwPageNo = pKid->GetRefObjNum(); 1275 pNode->m_dwPageNo = pKid->GetRefObjNum();
1283 } 1276 }
1284 pPages->Release(); 1277 delete pPages;
1285 return true; 1278 return true;
1286 } 1279 }
1287 1280
1288 bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo, 1281 bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
1289 PageNode* pPageNode, 1282 PageNode* pPageNode,
1290 DownloadHints* pHints) { 1283 DownloadHints* pHints) {
1291 bool bExist = false; 1284 bool bExist = false;
1292 CPDF_Object* pPage = GetObject(dwPageNo, pHints, &bExist); 1285 CPDF_Object* pPage = GetObject(dwPageNo, pHints, &bExist);
1293 if (!bExist) { 1286 if (!bExist) {
1294 m_docStatus = PDF_DATAAVAIL_ERROR; 1287 m_docStatus = PDF_DATAAVAIL_ERROR;
1295 return false; 1288 return false;
1296 } 1289 }
1297 1290
1298 if (!pPage) { 1291 if (!pPage) {
1299 if (m_docStatus == PDF_DATAAVAIL_ERROR) 1292 if (m_docStatus == PDF_DATAAVAIL_ERROR)
1300 m_docStatus = PDF_DATAAVAIL_ERROR; 1293 m_docStatus = PDF_DATAAVAIL_ERROR;
1301 return false; 1294 return false;
1302 } 1295 }
1303 1296
1304 if (pPage->IsArray()) { 1297 if (pPage->IsArray()) {
1305 pPageNode->m_dwPageNo = dwPageNo; 1298 pPageNode->m_dwPageNo = dwPageNo;
1306 pPageNode->m_type = PDF_PAGENODE_ARRAY; 1299 pPageNode->m_type = PDF_PAGENODE_ARRAY;
1307 pPage->Release(); 1300 delete pPage;
1308 return true; 1301 return true;
1309 } 1302 }
1310 1303
1311 if (!pPage->IsDictionary()) { 1304 if (!pPage->IsDictionary()) {
1312 pPage->Release(); 1305 delete pPage;
1313 m_docStatus = PDF_DATAAVAIL_ERROR; 1306 m_docStatus = PDF_DATAAVAIL_ERROR;
1314 return false; 1307 return false;
1315 } 1308 }
1316 1309
1317 pPageNode->m_dwPageNo = dwPageNo; 1310 pPageNode->m_dwPageNo = dwPageNo;
1318 CPDF_Dictionary* pDict = pPage->GetDict(); 1311 CPDF_Dictionary* pDict = pPage->GetDict();
1319 CFX_ByteString type = pDict->GetStringFor("Type"); 1312 CFX_ByteString type = pDict->GetStringFor("Type");
1320 if (type == "Pages") { 1313 if (type == "Pages") {
1321 pPageNode->m_type = PDF_PAGENODE_PAGES; 1314 pPageNode->m_type = PDF_PAGENODE_PAGES;
1322 CPDF_Object* pKids = pDict->GetObjectFor("Kids"); 1315 CPDF_Object* pKids = pDict->GetObjectFor("Kids");
(...skipping 20 matching lines...) Expand all
1343 pPageNode->m_childNode.Add(pNode); 1336 pPageNode->m_childNode.Add(pNode);
1344 pNode->m_dwPageNo = pKid->GetRefObjNum(); 1337 pNode->m_dwPageNo = pKid->GetRefObjNum();
1345 } 1338 }
1346 } break; 1339 } break;
1347 default: 1340 default:
1348 break; 1341 break;
1349 } 1342 }
1350 } else if (type == "Page") { 1343 } else if (type == "Page") {
1351 pPageNode->m_type = PDF_PAGENODE_PAGE; 1344 pPageNode->m_type = PDF_PAGENODE_PAGE;
1352 } else { 1345 } else {
1353 pPage->Release(); 1346 delete pPage;
1354 m_docStatus = PDF_DATAAVAIL_ERROR; 1347 m_docStatus = PDF_DATAAVAIL_ERROR;
1355 return false; 1348 return false;
1356 } 1349 }
1357 pPage->Release(); 1350 delete pPage;
1358 return true; 1351 return true;
1359 } 1352 }
1360 1353
1361 bool CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes, 1354 bool CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes,
1362 int32_t iPage, 1355 int32_t iPage,
1363 int32_t& iCount, 1356 int32_t& iCount,
1364 DownloadHints* pHints, 1357 DownloadHints* pHints,
1365 int level) { 1358 int level) {
1366 if (level >= kMaxPageRecursionDepth) 1359 if (level >= kMaxPageRecursionDepth)
1367 return false; 1360 return false;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 if (!bExist) { 1428 if (!bExist) {
1436 m_docStatus = PDF_DATAAVAIL_ERROR; 1429 m_docStatus = PDF_DATAAVAIL_ERROR;
1437 return false; 1430 return false;
1438 } 1431 }
1439 1432
1440 if (!pPages) 1433 if (!pPages)
1441 return false; 1434 return false;
1442 1435
1443 CPDF_Dictionary* pPagesDict = pPages->GetDict(); 1436 CPDF_Dictionary* pPagesDict = pPages->GetDict();
1444 if (!pPagesDict) { 1437 if (!pPagesDict) {
1445 pPages->Release(); 1438 delete pPages;
1446 m_docStatus = PDF_DATAAVAIL_ERROR; 1439 m_docStatus = PDF_DATAAVAIL_ERROR;
1447 return false; 1440 return false;
1448 } 1441 }
1449 1442
1450 if (!pPagesDict->KeyExist("Kids")) { 1443 if (!pPagesDict->KeyExist("Kids")) {
1451 pPages->Release(); 1444 delete pPages;
1452 return true; 1445 return true;
1453 } 1446 }
1454 1447
1455 int count = pPagesDict->GetIntegerFor("Count"); 1448 int count = pPagesDict->GetIntegerFor("Count");
1456 if (count > 0) { 1449 if (count > 0) {
1457 pPages->Release(); 1450 delete pPages;
1458 return true; 1451 return true;
1459 } 1452 }
1460 1453
1461 pPages->Release(); 1454 delete pPages;
1462 return false; 1455 return false;
1463 } 1456 }
1464 1457
1465 bool CPDF_DataAvail::LoadDocPages(DownloadHints* pHints) { 1458 bool CPDF_DataAvail::LoadDocPages(DownloadHints* pHints) {
1466 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) 1459 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints))
1467 return false; 1460 return false;
1468 1461
1469 if (CheckPageCount(pHints)) { 1462 if (CheckPageCount(pHints)) {
1470 m_docStatus = PDF_DATAAVAIL_PAGE; 1463 m_docStatus = PDF_DATAAVAIL_PAGE;
1471 return true; 1464 return true;
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 return FormAvailable; 1809 return FormAvailable;
1817 } 1810 }
1818 1811
1819 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} 1812 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {}
1820 1813
1821 CPDF_DataAvail::PageNode::~PageNode() { 1814 CPDF_DataAvail::PageNode::~PageNode() {
1822 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) 1815 for (int32_t i = 0; i < m_childNode.GetSize(); ++i)
1823 delete m_childNode[i]; 1816 delete m_childNode[i];
1824 m_childNode.RemoveAll(); 1817 m_childNode.RemoveAll();
1825 } 1818 }
OLDNEW
« 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