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

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: nits Created 4 years, 2 months 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 m_pPageResource = nullptr; 75 m_pPageResource = nullptr;
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 CPDF_DataAvail::~CPDF_DataAvail() { 83 CPDF_DataAvail::~CPDF_DataAvail() {
84 m_pHintTables.reset(); 84 m_pHintTables.reset();
85 if (m_pLinearized) 85 delete m_pLinearized;
86 m_pLinearized->Release(); 86 delete m_pRoot;
87 87 delete m_pTrailer;
88 if (m_pRoot)
89 m_pRoot->Release();
90
91 if (m_pTrailer)
92 m_pTrailer->Release();
93 88
94 int iSize = m_arrayAcroforms.GetSize(); 89 int iSize = m_arrayAcroforms.GetSize();
95 for (int i = 0; i < iSize; ++i) 90 for (int i = 0; i < iSize; ++i)
96 m_arrayAcroforms.GetAt(i)->Release(); 91 delete m_arrayAcroforms.GetAt(i);
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (bRet) 224 if (bRet)
230 m_objs_array.RemoveAll(); 225 m_objs_array.RemoveAll();
231 return bRet; 226 return bRet;
232 } 227 }
233 228
234 CFX_ArrayTemplate<CPDF_Object*> new_objs_array; 229 CFX_ArrayTemplate<CPDF_Object*> new_objs_array;
235 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); 230 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array);
236 if (bRet) { 231 if (bRet) {
237 int32_t iSize = m_arrayAcroforms.GetSize(); 232 int32_t iSize = m_arrayAcroforms.GetSize();
238 for (int32_t i = 0; i < iSize; ++i) { 233 for (int32_t i = 0; i < iSize; ++i) {
239 m_arrayAcroforms.GetAt(i)->Release(); 234 delete m_arrayAcroforms.GetAt(i);
240 } 235 }
241 m_arrayAcroforms.RemoveAll(); 236 m_arrayAcroforms.RemoveAll();
242 } else { 237 } else {
243 m_objs_array.RemoveAll(); 238 m_objs_array.RemoveAll();
244 m_objs_array.Append(new_objs_array); 239 m_objs_array.Append(new_objs_array);
245 } 240 }
246 return bRet; 241 return bRet;
247 } 242 }
248 243
249 FX_BOOL CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) { 244 FX_BOOL CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (m_docStatus == PDF_DATAAVAIL_ERROR) { 398 if (m_docStatus == PDF_DATAAVAIL_ERROR) {
404 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; 399 m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
405 return TRUE; 400 return TRUE;
406 } 401 }
407 402
408 if (m_Pos == m_dwFileLen) 403 if (m_Pos == m_dwFileLen)
409 m_docStatus = PDF_DATAAVAIL_ERROR; 404 m_docStatus = PDF_DATAAVAIL_ERROR;
410 return FALSE; 405 return FALSE;
411 } 406 }
412 407
413 if (pInfo) 408 delete pInfo;
414 pInfo->Release();
415
416 m_docStatus = 409 m_docStatus =
417 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE); 410 (m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE);
418 411
419 return TRUE; 412 return TRUE;
420 } 413 }
421 414
422 FX_BOOL CPDF_DataAvail::CheckRoot(DownloadHints* pHints) { 415 FX_BOOL CPDF_DataAvail::CheckRoot(DownloadHints* pHints) {
423 FX_BOOL bExist = FALSE; 416 FX_BOOL bExist = FALSE;
424 m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist); 417 m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist);
425 if (!bExist) { 418 if (!bExist) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 495
503 CPDF_Array* pArray = ToArray(pObj); 496 CPDF_Array* pArray = ToArray(pObj);
504 if (pArray) { 497 if (pArray) {
505 for (CPDF_Object* pArrayObj : *pArray) { 498 for (CPDF_Object* pArrayObj : *pArray) {
506 if (CPDF_Reference* pRef = ToReference(pArrayObj)) 499 if (CPDF_Reference* pRef = ToReference(pArrayObj))
507 UnavailObjList.Add(pRef->GetRefObjNum()); 500 UnavailObjList.Add(pRef->GetRefObjNum());
508 } 501 }
509 } 502 }
510 503
511 if (!pObj->IsDictionary()) { 504 if (!pObj->IsDictionary()) {
512 pObj->Release(); 505 delete pObj;
513 continue; 506 continue;
514 } 507 }
515 508
516 CFX_ByteString type = pObj->GetDict()->GetStringFor("Type"); 509 CFX_ByteString type = pObj->GetDict()->GetStringFor("Type");
517 if (type == "Pages") { 510 if (type == "Pages") {
518 m_PagesArray.Add(pObj); 511 m_PagesArray.Add(pObj);
519 continue; 512 continue;
520 } 513 }
521 pObj->Release(); 514 delete pObj;
522 } 515 }
523 516
524 m_PageObjList.RemoveAll(); 517 m_PageObjList.RemoveAll();
525 if (UnavailObjList.GetSize()) { 518 if (UnavailObjList.GetSize()) {
526 m_PageObjList.Append(UnavailObjList); 519 m_PageObjList.Append(UnavailObjList);
527 return FALSE; 520 return FALSE;
528 } 521 }
529 522
530 uint32_t iPages = m_PagesArray.GetSize(); 523 uint32_t iPages = m_PagesArray.GetSize();
531 for (uint32_t i = 0; i < iPages; i++) { 524 for (uint32_t i = 0; i < iPages; i++) {
532 CPDF_Object* pPages = m_PagesArray.GetAt(i); 525 CPDF_Object* pPages = m_PagesArray.GetAt(i);
533 if (!pPages) 526 if (!pPages)
534 continue; 527 continue;
535 528
536 if (!GetPageKids(m_pCurrentParser, pPages)) { 529 if (!GetPageKids(m_pCurrentParser, pPages)) {
537 pPages->Release(); 530 delete pPages;
538 while (++i < iPages) { 531 while (++i < iPages) {
539 pPages = m_PagesArray.GetAt(i); 532 pPages = m_PagesArray.GetAt(i);
540 pPages->Release(); 533 delete pPages;
541 } 534 }
542 m_PagesArray.RemoveAll(); 535 m_PagesArray.RemoveAll();
543 536
544 m_docStatus = PDF_DATAAVAIL_ERROR; 537 m_docStatus = PDF_DATAAVAIL_ERROR;
545 return FALSE; 538 return FALSE;
546 } 539 }
547 pPages->Release(); 540 delete pPages;
548 } 541 }
549 542
550 m_PagesArray.RemoveAll(); 543 m_PagesArray.RemoveAll();
551 if (!m_PageObjList.GetSize()) 544 if (!m_PageObjList.GetSize())
552 m_docStatus = PDF_DATAAVAIL_DONE; 545 m_docStatus = PDF_DATAAVAIL_DONE;
553 return TRUE; 546 return TRUE;
554 } 547 }
555 548
556 FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { 549 FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) {
557 if (!pParser) { 550 if (!pParser) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 585
593 if (!pPages) { 586 if (!pPages) {
594 if (m_docStatus == PDF_DATAAVAIL_ERROR) { 587 if (m_docStatus == PDF_DATAAVAIL_ERROR) {
595 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; 588 m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
596 return TRUE; 589 return TRUE;
597 } 590 }
598 return FALSE; 591 return FALSE;
599 } 592 }
600 593
601 if (!GetPageKids(m_pCurrentParser, pPages)) { 594 if (!GetPageKids(m_pCurrentParser, pPages)) {
602 pPages->Release(); 595 delete pPages;
603 m_docStatus = PDF_DATAAVAIL_ERROR; 596 m_docStatus = PDF_DATAAVAIL_ERROR;
604 return FALSE; 597 return FALSE;
605 } 598 }
606 599
607 pPages->Release(); 600 delete pPages;
608 m_docStatus = PDF_DATAAVAIL_PAGE; 601 m_docStatus = PDF_DATAAVAIL_PAGE;
609 return TRUE; 602 return TRUE;
610 } 603 }
611 604
612 FX_BOOL CPDF_DataAvail::CheckHeader(DownloadHints* pHints) { 605 FX_BOOL CPDF_DataAvail::CheckHeader(DownloadHints* pHints) {
613 ASSERT(m_dwFileLen >= 0); 606 ASSERT(m_dwFileLen >= 0);
614 const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U); 607 const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U);
615 608
616 if (m_pFileAvail->IsDataAvail(0, kReqSize)) { 609 if (m_pFileAvail->IsDataAvail(0, kReqSize)) {
617 uint8_t buffer[1024]; 610 uint8_t buffer[1024];
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 return FALSE; 761 return FALSE;
769 } 762 }
770 763
771 if (!IsDataAvail(szHintStart, szHintLength, pHints)) 764 if (!IsDataAvail(szHintStart, szHintLength, pHints))
772 return FALSE; 765 return FALSE;
773 766
774 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); 767 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset);
775 768
776 std::unique_ptr<CPDF_HintTables> pHintTables( 769 std::unique_ptr<CPDF_HintTables> pHintTables(
777 new CPDF_HintTables(this, pDict)); 770 new CPDF_HintTables(this, pDict));
778 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pHintStream( 771 std::unique_ptr<CPDF_Object> pHintStream(
779 ParseIndirectObjectAt(szHintStart, 0)); 772 ParseIndirectObjectAt(szHintStart, 0));
780 CPDF_Stream* pStream = ToStream(pHintStream.get()); 773 CPDF_Stream* pStream = ToStream(pHintStream.get());
781 if (pStream && pHintTables->LoadHintStream(pStream)) 774 if (pStream && pHintTables->LoadHintStream(pStream))
782 m_pHintTables = std::move(pHintTables); 775 m_pHintTables = std::move(pHintTables);
783 776
784 m_docStatus = PDF_DATAAVAIL_DONE; 777 m_docStatus = PDF_DATAAVAIL_DONE;
785 return TRUE; 778 return TRUE;
786 } 779 }
787 780
788 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt( 781 CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt(
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 m_Pos += m_parser.m_pSyntax->SavePos(); 949 m_Pos += m_parser.m_pSyntax->SavePos();
957 return 0; 950 return 0;
958 } 951 }
959 952
960 CPDF_Dictionary* pDict = pObj->GetDict(); 953 CPDF_Dictionary* pDict = pObj->GetDict();
961 CPDF_Name* pName = ToName(pDict ? pDict->GetObjectFor("Type") : nullptr); 954 CPDF_Name* pName = ToName(pDict ? pDict->GetObjectFor("Type") : nullptr);
962 if (pName) { 955 if (pName) {
963 if (pName->GetString() == "XRef") { 956 if (pName->GetString() == "XRef") {
964 m_Pos += m_parser.m_pSyntax->SavePos(); 957 m_Pos += m_parser.m_pSyntax->SavePos();
965 xref_offset = pObj->GetDict()->GetIntegerFor("Prev"); 958 xref_offset = pObj->GetDict()->GetIntegerFor("Prev");
966 pObj->Release(); 959 delete pObj;
967 return 1; 960 return 1;
968 } 961 }
969 } 962 }
970 pObj->Release(); 963 delete pObj;
971 return -1; 964 return -1;
972 } 965 }
973 pHints->AddSegment(m_Pos, req_size); 966 pHints->AddSegment(m_Pos, req_size);
974 return 0; 967 return 0;
975 } 968 }
976 969
977 void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) { 970 void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) {
978 m_Pos = dwOffset; 971 m_Pos = dwOffset;
979 } 972 }
980 973
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 m_docStatus = PDF_DATAAVAIL_ERROR; 1179 m_docStatus = PDF_DATAAVAIL_ERROR;
1187 return FALSE; 1180 return FALSE;
1188 } 1181 }
1189 1182
1190 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) 1183 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize))
1191 return FALSE; 1184 return FALSE;
1192 1185
1193 ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); 1186 ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE));
1194 m_syntaxParser.InitParser(file.get(), 0); 1187 m_syntaxParser.InitParser(file.get(), 0);
1195 1188
1196 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pTrailer( 1189 std::unique_ptr<CPDF_Object> pTrailer(
1197 m_syntaxParser.GetObject(nullptr, 0, 0, true)); 1190 m_syntaxParser.GetObject(nullptr, 0, 0, true));
1198 if (!pTrailer) { 1191 if (!pTrailer) {
1199 m_Pos += m_syntaxParser.SavePos(); 1192 m_Pos += m_syntaxParser.SavePos();
1200 pHints->AddSegment(m_Pos, iTrailerSize); 1193 pHints->AddSegment(m_Pos, iTrailerSize);
1201 return FALSE; 1194 return FALSE;
1202 } 1195 }
1203 1196
1204 if (!pTrailer->IsDictionary()) 1197 if (!pTrailer->IsDictionary())
1205 return FALSE; 1198 return FALSE;
1206 1199
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 if (!pPages) { 1264 if (!pPages) {
1272 if (m_docStatus == PDF_DATAAVAIL_ERROR) { 1265 if (m_docStatus == PDF_DATAAVAIL_ERROR) {
1273 m_docStatus = PDF_DATAAVAIL_ERROR; 1266 m_docStatus = PDF_DATAAVAIL_ERROR;
1274 return FALSE; 1267 return FALSE;
1275 } 1268 }
1276 return FALSE; 1269 return FALSE;
1277 } 1270 }
1278 1271
1279 CPDF_Array* pArray = pPages->AsArray(); 1272 CPDF_Array* pArray = pPages->AsArray();
1280 if (!pArray) { 1273 if (!pArray) {
1281 pPages->Release(); 1274 delete pPages;
1282 m_docStatus = PDF_DATAAVAIL_ERROR; 1275 m_docStatus = PDF_DATAAVAIL_ERROR;
1283 return FALSE; 1276 return FALSE;
1284 } 1277 }
1285 1278
1286 pPageNode->m_type = PDF_PAGENODE_PAGES; 1279 pPageNode->m_type = PDF_PAGENODE_PAGES;
1287 for (size_t i = 0; i < pArray->GetCount(); ++i) { 1280 for (size_t i = 0; i < pArray->GetCount(); ++i) {
1288 CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i)); 1281 CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i));
1289 if (!pKid) 1282 if (!pKid)
1290 continue; 1283 continue;
1291 1284
1292 PageNode* pNode = new PageNode(); 1285 PageNode* pNode = new PageNode();
1293 pPageNode->m_childNode.Add(pNode); 1286 pPageNode->m_childNode.Add(pNode);
1294 pNode->m_dwPageNo = pKid->GetRefObjNum(); 1287 pNode->m_dwPageNo = pKid->GetRefObjNum();
1295 } 1288 }
1296 pPages->Release(); 1289 delete pPages;
1297 return TRUE; 1290 return TRUE;
1298 } 1291 }
1299 1292
1300 FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo, 1293 FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
1301 PageNode* pPageNode, 1294 PageNode* pPageNode,
1302 DownloadHints* pHints) { 1295 DownloadHints* pHints) {
1303 FX_BOOL bExist = FALSE; 1296 FX_BOOL bExist = FALSE;
1304 CPDF_Object* pPage = GetObject(dwPageNo, pHints, &bExist); 1297 CPDF_Object* pPage = GetObject(dwPageNo, pHints, &bExist);
1305 if (!bExist) { 1298 if (!bExist) {
1306 m_docStatus = PDF_DATAAVAIL_ERROR; 1299 m_docStatus = PDF_DATAAVAIL_ERROR;
1307 return FALSE; 1300 return FALSE;
1308 } 1301 }
1309 1302
1310 if (!pPage) { 1303 if (!pPage) {
1311 if (m_docStatus == PDF_DATAAVAIL_ERROR) 1304 if (m_docStatus == PDF_DATAAVAIL_ERROR)
1312 m_docStatus = PDF_DATAAVAIL_ERROR; 1305 m_docStatus = PDF_DATAAVAIL_ERROR;
1313 return FALSE; 1306 return FALSE;
1314 } 1307 }
1315 1308
1316 if (pPage->IsArray()) { 1309 if (pPage->IsArray()) {
1317 pPageNode->m_dwPageNo = dwPageNo; 1310 pPageNode->m_dwPageNo = dwPageNo;
1318 pPageNode->m_type = PDF_PAGENODE_ARRAY; 1311 pPageNode->m_type = PDF_PAGENODE_ARRAY;
1319 pPage->Release(); 1312 delete pPage;
1320 return TRUE; 1313 return TRUE;
1321 } 1314 }
1322 1315
1323 if (!pPage->IsDictionary()) { 1316 if (!pPage->IsDictionary()) {
1324 pPage->Release(); 1317 delete pPage;
1325 m_docStatus = PDF_DATAAVAIL_ERROR; 1318 m_docStatus = PDF_DATAAVAIL_ERROR;
1326 return FALSE; 1319 return FALSE;
1327 } 1320 }
1328 1321
1329 pPageNode->m_dwPageNo = dwPageNo; 1322 pPageNode->m_dwPageNo = dwPageNo;
1330 CPDF_Dictionary* pDict = pPage->GetDict(); 1323 CPDF_Dictionary* pDict = pPage->GetDict();
1331 CFX_ByteString type = pDict->GetStringFor("Type"); 1324 CFX_ByteString type = pDict->GetStringFor("Type");
1332 if (type == "Pages") { 1325 if (type == "Pages") {
1333 pPageNode->m_type = PDF_PAGENODE_PAGES; 1326 pPageNode->m_type = PDF_PAGENODE_PAGES;
1334 CPDF_Object* pKids = pDict->GetObjectFor("Kids"); 1327 CPDF_Object* pKids = pDict->GetObjectFor("Kids");
(...skipping 20 matching lines...) Expand all
1355 pPageNode->m_childNode.Add(pNode); 1348 pPageNode->m_childNode.Add(pNode);
1356 pNode->m_dwPageNo = pKid->GetRefObjNum(); 1349 pNode->m_dwPageNo = pKid->GetRefObjNum();
1357 } 1350 }
1358 } break; 1351 } break;
1359 default: 1352 default:
1360 break; 1353 break;
1361 } 1354 }
1362 } else if (type == "Page") { 1355 } else if (type == "Page") {
1363 pPageNode->m_type = PDF_PAGENODE_PAGE; 1356 pPageNode->m_type = PDF_PAGENODE_PAGE;
1364 } else { 1357 } else {
1365 pPage->Release(); 1358 delete pPage;
1366 m_docStatus = PDF_DATAAVAIL_ERROR; 1359 m_docStatus = PDF_DATAAVAIL_ERROR;
1367 return FALSE; 1360 return FALSE;
1368 } 1361 }
1369 pPage->Release(); 1362 delete pPage;
1370 return TRUE; 1363 return TRUE;
1371 } 1364 }
1372 1365
1373 FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes, 1366 FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes,
1374 int32_t iPage, 1367 int32_t iPage,
1375 int32_t& iCount, 1368 int32_t& iCount,
1376 DownloadHints* pHints, 1369 DownloadHints* pHints,
1377 int level) { 1370 int level) {
1378 if (level >= kMaxPageRecursionDepth) 1371 if (level >= kMaxPageRecursionDepth)
1379 return FALSE; 1372 return FALSE;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 } 1429 }
1437 m_docStatus = PDF_DATAAVAIL_ERROR; 1430 m_docStatus = PDF_DATAAVAIL_ERROR;
1438 return TRUE; 1431 return TRUE;
1439 } 1432 }
1440 int32_t iCount = -1; 1433 int32_t iCount = -1;
1441 return CheckPageNode(m_pageNodes, iPage, iCount, pHints, 0); 1434 return CheckPageNode(m_pageNodes, iPage, iCount, pHints, 0);
1442 } 1435 }
1443 1436
1444 FX_BOOL CPDF_DataAvail::CheckPageCount(DownloadHints* pHints) { 1437 FX_BOOL CPDF_DataAvail::CheckPageCount(DownloadHints* pHints) {
1445 FX_BOOL bExist = FALSE; 1438 FX_BOOL bExist = FALSE;
1446 CPDF_Object* pPages = GetObject(m_PagesObjNum, pHints, &bExist); 1439 CPDF_Object* pPages = GetObject(m_PagesObjNum, pHints, &bExist);
Lei Zhang 2016/10/05 21:09:25 For later: unique_ptr.
1447 if (!bExist) { 1440 if (!bExist) {
1448 m_docStatus = PDF_DATAAVAIL_ERROR; 1441 m_docStatus = PDF_DATAAVAIL_ERROR;
1449 return FALSE; 1442 return FALSE;
1450 } 1443 }
1451 1444
1452 if (!pPages) 1445 if (!pPages)
1453 return FALSE; 1446 return FALSE;
1454 1447
1455 CPDF_Dictionary* pPagesDict = pPages->GetDict(); 1448 CPDF_Dictionary* pPagesDict = pPages->GetDict();
1456 if (!pPagesDict) { 1449 if (!pPagesDict) {
1457 pPages->Release(); 1450 delete pPages;
1458 m_docStatus = PDF_DATAAVAIL_ERROR; 1451 m_docStatus = PDF_DATAAVAIL_ERROR;
1459 return FALSE; 1452 return FALSE;
1460 } 1453 }
1461 1454
1462 if (!pPagesDict->KeyExist("Kids")) { 1455 if (!pPagesDict->KeyExist("Kids")) {
1463 pPages->Release(); 1456 delete pPages;
1464 return TRUE; 1457 return TRUE;
1465 } 1458 }
1466 1459
1467 int count = pPagesDict->GetIntegerFor("Count"); 1460 int count = pPagesDict->GetIntegerFor("Count");
1468 if (count > 0) { 1461 if (count > 0) {
1469 pPages->Release(); 1462 delete pPages;
1470 return TRUE; 1463 return TRUE;
1471 } 1464 }
1472 1465
1473 pPages->Release(); 1466 delete pPages;
1474 return FALSE; 1467 return FALSE;
1475 } 1468 }
1476 1469
1477 FX_BOOL CPDF_DataAvail::LoadDocPages(DownloadHints* pHints) { 1470 FX_BOOL CPDF_DataAvail::LoadDocPages(DownloadHints* pHints) {
1478 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) 1471 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints))
1479 return FALSE; 1472 return FALSE;
1480 1473
1481 if (CheckPageCount(pHints)) { 1474 if (CheckPageCount(pHints)) {
1482 m_docStatus = PDF_DATAAVAIL_PAGE; 1475 m_docStatus = PDF_DATAAVAIL_PAGE;
1483 return TRUE; 1476 return TRUE;
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 return FormAvailable; 1828 return FormAvailable;
1836 } 1829 }
1837 1830
1838 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} 1831 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {}
1839 1832
1840 CPDF_DataAvail::PageNode::~PageNode() { 1833 CPDF_DataAvail::PageNode::~PageNode() {
1841 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) 1834 for (int32_t i = 0; i < m_childNode.GetSize(); ++i)
1842 delete m_childNode[i]; 1835 delete m_childNode[i];
1843 m_childNode.RemoveAll(); 1836 m_childNode.RemoveAll();
1844 } 1837 }
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