OLD | NEW |
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_parser.h" | 7 #include "core/fpdfapi/parser/cpdf_parser.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 m_pTrailer(nullptr), | 54 m_pTrailer(nullptr), |
55 m_pEncryptDict(nullptr), | 55 m_pEncryptDict(nullptr), |
56 m_bVersionUpdated(false), | 56 m_bVersionUpdated(false), |
57 m_pLinearized(nullptr), | 57 m_pLinearized(nullptr), |
58 m_dwFirstPageNo(0), | 58 m_dwFirstPageNo(0), |
59 m_dwXrefStartObjNum(0) { | 59 m_dwXrefStartObjNum(0) { |
60 m_pSyntax.reset(new CPDF_SyntaxParser); | 60 m_pSyntax.reset(new CPDF_SyntaxParser); |
61 } | 61 } |
62 | 62 |
63 CPDF_Parser::~CPDF_Parser() { | 63 CPDF_Parser::~CPDF_Parser() { |
64 delete m_pTrailer; | 64 if (m_pTrailer) |
| 65 m_pTrailer->Release(); |
| 66 |
65 ReleaseEncryptHandler(); | 67 ReleaseEncryptHandler(); |
66 SetEncryptDictionary(nullptr); | 68 SetEncryptDictionary(nullptr); |
67 | 69 |
68 if (m_bOwnFileRead && m_pSyntax->m_pFileAccess) { | 70 if (m_bOwnFileRead && m_pSyntax->m_pFileAccess) { |
69 m_pSyntax->m_pFileAccess->Release(); | 71 m_pSyntax->m_pFileAccess->Release(); |
70 m_pSyntax->m_pFileAccess = nullptr; | 72 m_pSyntax->m_pFileAccess = nullptr; |
71 } | 73 } |
72 | 74 |
73 for (CPDF_Dictionary* trailer : m_Trailers) | 75 for (CPDF_Dictionary* trailer : m_Trailers) { |
74 delete trailer; | 76 if (trailer) |
| 77 trailer->Release(); |
| 78 } |
75 | 79 |
76 delete m_pLinearized; | 80 if (m_pLinearized) |
| 81 m_pLinearized->Release(); |
77 } | 82 } |
78 | 83 |
79 uint32_t CPDF_Parser::GetLastObjNum() const { | 84 uint32_t CPDF_Parser::GetLastObjNum() const { |
80 return m_ObjectInfo.empty() ? 0 : m_ObjectInfo.rbegin()->first; | 85 return m_ObjectInfo.empty() ? 0 : m_ObjectInfo.rbegin()->first; |
81 } | 86 } |
82 | 87 |
83 bool CPDF_Parser::IsValidObjectNumber(uint32_t objnum) const { | 88 bool CPDF_Parser::IsValidObjectNumber(uint32_t objnum) const { |
84 return !m_ObjectInfo.empty() && objnum <= m_ObjectInfo.rbegin()->first; | 89 return !m_ObjectInfo.empty() && objnum <= m_ObjectInfo.rbegin()->first; |
85 } | 90 } |
86 | 91 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // Check for circular references. | 350 // Check for circular references. |
346 if (pdfium::ContainsKey(seen_xrefpos, xrefpos)) | 351 if (pdfium::ContainsKey(seen_xrefpos, xrefpos)) |
347 return false; | 352 return false; |
348 | 353 |
349 seen_xrefpos.insert(xrefpos); | 354 seen_xrefpos.insert(xrefpos); |
350 | 355 |
351 // SLOW ... | 356 // SLOW ... |
352 CrossRefList.insert(CrossRefList.begin(), xrefpos); | 357 CrossRefList.insert(CrossRefList.begin(), xrefpos); |
353 LoadCrossRefV4(xrefpos, 0, true); | 358 LoadCrossRefV4(xrefpos, 0, true); |
354 | 359 |
355 std::unique_ptr<CPDF_Dictionary> pDict(LoadTrailerV4()); | 360 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( |
| 361 LoadTrailerV4()); |
356 if (!pDict) | 362 if (!pDict) |
357 return false; | 363 return false; |
358 | 364 |
359 xrefpos = GetDirectInteger(pDict.get(), "Prev"); | 365 xrefpos = GetDirectInteger(pDict.get(), "Prev"); |
360 | 366 |
361 // SLOW ... | 367 // SLOW ... |
362 XRefStreamList.insert(XRefStreamList.begin(), | 368 XRefStreamList.insert(XRefStreamList.begin(), |
363 pDict->GetIntegerFor("XRefStm")); | 369 pDict->GetIntegerFor("XRefStm")); |
364 m_Trailers.push_back(pDict.release()); | 370 m_Trailers.push_back(pDict.release()); |
365 } | 371 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // Check for circular references. | 405 // Check for circular references. |
400 if (pdfium::ContainsKey(seen_xrefpos, xrefpos)) | 406 if (pdfium::ContainsKey(seen_xrefpos, xrefpos)) |
401 return false; | 407 return false; |
402 | 408 |
403 seen_xrefpos.insert(xrefpos); | 409 seen_xrefpos.insert(xrefpos); |
404 | 410 |
405 // SLOW ... | 411 // SLOW ... |
406 CrossRefList.insert(CrossRefList.begin(), xrefpos); | 412 CrossRefList.insert(CrossRefList.begin(), xrefpos); |
407 LoadCrossRefV4(xrefpos, 0, true); | 413 LoadCrossRefV4(xrefpos, 0, true); |
408 | 414 |
409 std::unique_ptr<CPDF_Dictionary> pDict(LoadTrailerV4()); | 415 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( |
| 416 LoadTrailerV4()); |
410 if (!pDict) | 417 if (!pDict) |
411 return false; | 418 return false; |
412 | 419 |
413 xrefpos = GetDirectInteger(pDict.get(), "Prev"); | 420 xrefpos = GetDirectInteger(pDict.get(), "Prev"); |
414 | 421 |
415 // SLOW ... | 422 // SLOW ... |
416 XRefStreamList.insert(XRefStreamList.begin(), | 423 XRefStreamList.insert(XRefStreamList.begin(), |
417 pDict->GetIntegerFor("XRefStm")); | 424 pDict->GetIntegerFor("XRefStm")); |
418 m_Trailers.push_back(pDict.release()); | 425 m_Trailers.push_back(pDict.release()); |
419 } | 426 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 return false; | 583 return false; |
577 } | 584 } |
578 m_ObjectStreamMap.clear(); | 585 m_ObjectStreamMap.clear(); |
579 m_bXRefStream = true; | 586 m_bXRefStream = true; |
580 return true; | 587 return true; |
581 } | 588 } |
582 | 589 |
583 bool CPDF_Parser::RebuildCrossRef() { | 590 bool CPDF_Parser::RebuildCrossRef() { |
584 m_ObjectInfo.clear(); | 591 m_ObjectInfo.clear(); |
585 m_SortedOffset.clear(); | 592 m_SortedOffset.clear(); |
586 delete m_pTrailer; | 593 if (m_pTrailer) { |
587 m_pTrailer = nullptr; | 594 m_pTrailer->Release(); |
| 595 m_pTrailer = nullptr; |
| 596 } |
588 | 597 |
589 ParserState state = ParserState::kDefault; | 598 ParserState state = ParserState::kDefault; |
| 599 |
590 int32_t inside_index = 0; | 600 int32_t inside_index = 0; |
591 uint32_t objnum = 0; | 601 uint32_t objnum = 0; |
592 uint32_t gennum = 0; | 602 uint32_t gennum = 0; |
593 int32_t depth = 0; | 603 int32_t depth = 0; |
| 604 |
594 const uint32_t kBufferSize = 4096; | 605 const uint32_t kBufferSize = 4096; |
595 std::vector<uint8_t> buffer(kBufferSize); | 606 std::vector<uint8_t> buffer(kBufferSize); |
596 | 607 |
597 FX_FILESIZE pos = m_pSyntax->m_HeaderOffset; | 608 FX_FILESIZE pos = m_pSyntax->m_HeaderOffset; |
598 FX_FILESIZE start_pos = 0; | 609 FX_FILESIZE start_pos = 0; |
599 FX_FILESIZE start_pos1 = 0; | 610 FX_FILESIZE start_pos1 = 0; |
600 FX_FILESIZE last_obj = -1; | 611 FX_FILESIZE last_obj = -1; |
601 FX_FILESIZE last_xref = -1; | 612 FX_FILESIZE last_xref = -1; |
602 FX_FILESIZE last_trailer = -1; | 613 FX_FILESIZE last_trailer = -1; |
603 | 614 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 CPDF_Object* pObject = ParseIndirectObjectAtByStrict( | 748 CPDF_Object* pObject = ParseIndirectObjectAtByStrict( |
738 m_pDocument, obj_pos, objnum, &obj_end); | 749 m_pDocument, obj_pos, objnum, &obj_end); |
739 if (CPDF_Stream* pStream = ToStream(pObject)) { | 750 if (CPDF_Stream* pStream = ToStream(pObject)) { |
740 if (CPDF_Dictionary* pDict = pStream->GetDict()) { | 751 if (CPDF_Dictionary* pDict = pStream->GetDict()) { |
741 if ((pDict->KeyExist("Type")) && | 752 if ((pDict->KeyExist("Type")) && |
742 (pDict->GetStringFor("Type") == "XRef" && | 753 (pDict->GetStringFor("Type") == "XRef" && |
743 pDict->KeyExist("Size"))) { | 754 pDict->KeyExist("Size"))) { |
744 CPDF_Object* pRoot = pDict->GetObjectFor("Root"); | 755 CPDF_Object* pRoot = pDict->GetObjectFor("Root"); |
745 if (pRoot && pRoot->GetDict() && | 756 if (pRoot && pRoot->GetDict() && |
746 pRoot->GetDict()->GetObjectFor("Pages")) { | 757 pRoot->GetDict()->GetObjectFor("Pages")) { |
747 delete m_pTrailer; | 758 if (m_pTrailer) |
| 759 m_pTrailer->Release(); |
748 m_pTrailer = ToDictionary(pDict->Clone()); | 760 m_pTrailer = ToDictionary(pDict->Clone()); |
749 } | 761 } |
750 } | 762 } |
751 } | 763 } |
752 } | 764 } |
753 | 765 |
754 FX_FILESIZE offset = 0; | 766 FX_FILESIZE offset = 0; |
755 m_pSyntax->RestorePos(obj_pos); | 767 m_pSyntax->RestorePos(obj_pos); |
756 offset = m_pSyntax->FindTag("obj", 0); | 768 offset = m_pSyntax->FindTag("obj", 0); |
757 if (offset == -1) | 769 if (offset == -1) |
(...skipping 17 matching lines...) Expand all Loading... |
775 m_ObjectInfo[objnum].gennum = gennum; | 787 m_ObjectInfo[objnum].gennum = gennum; |
776 if (oldgen != gennum) | 788 if (oldgen != gennum) |
777 m_bVersionUpdated = true; | 789 m_bVersionUpdated = true; |
778 } | 790 } |
779 } else { | 791 } else { |
780 m_ObjectInfo[objnum].pos = obj_pos; | 792 m_ObjectInfo[objnum].pos = obj_pos; |
781 m_ObjectInfo[objnum].type = 1; | 793 m_ObjectInfo[objnum].type = 1; |
782 m_ObjectInfo[objnum].gennum = gennum; | 794 m_ObjectInfo[objnum].gennum = gennum; |
783 } | 795 } |
784 | 796 |
785 delete pObject; | 797 if (pObject) |
| 798 pObject->Release(); |
786 } | 799 } |
787 --i; | 800 --i; |
788 state = ParserState::kDefault; | 801 state = ParserState::kDefault; |
789 break; | 802 break; |
790 } | 803 } |
791 break; | 804 break; |
792 | 805 |
793 case ParserState::kTrailer: | 806 case ParserState::kTrailer: |
794 if (inside_index == 7) { | 807 if (inside_index == 7) { |
795 if (PDFCharIsWhitespace(byte) || PDFCharIsDelimiter(byte)) { | 808 if (PDFCharIsWhitespace(byte) || PDFCharIsDelimiter(byte)) { |
796 last_trailer = pos + i - 7; | 809 last_trailer = pos + i - 7; |
797 m_pSyntax->RestorePos(pos + i - m_pSyntax->m_HeaderOffset); | 810 m_pSyntax->RestorePos(pos + i - m_pSyntax->m_HeaderOffset); |
798 | 811 |
799 CPDF_Object* pObj = m_pSyntax->GetObject(m_pDocument, 0, 0, true); | 812 CPDF_Object* pObj = m_pSyntax->GetObject(m_pDocument, 0, 0, true); |
800 if (pObj) { | 813 if (pObj) { |
801 if (!pObj->IsDictionary() && !pObj->AsStream()) { | 814 if (!pObj->IsDictionary() && !pObj->AsStream()) { |
802 delete pObj; | 815 pObj->Release(); |
803 } else { | 816 } else { |
804 CPDF_Stream* pStream = pObj->AsStream(); | 817 CPDF_Stream* pStream = pObj->AsStream(); |
805 if (CPDF_Dictionary* pTrailer = | 818 if (CPDF_Dictionary* pTrailer = |
806 pStream ? pStream->GetDict() : pObj->AsDictionary()) { | 819 pStream ? pStream->GetDict() : pObj->AsDictionary()) { |
807 if (m_pTrailer) { | 820 if (m_pTrailer) { |
808 CPDF_Object* pRoot = pTrailer->GetObjectFor("Root"); | 821 CPDF_Object* pRoot = pTrailer->GetObjectFor("Root"); |
809 CPDF_Reference* pRef = ToReference(pRoot); | 822 CPDF_Reference* pRef = ToReference(pRoot); |
810 if (!pRoot || | 823 if (!pRoot || |
811 (pRef && IsValidObjectNumber(pRef->GetRefObjNum()) && | 824 (pRef && IsValidObjectNumber(pRef->GetRefObjNum()) && |
812 m_ObjectInfo[pRef->GetRefObjNum()].pos != 0)) { | 825 m_ObjectInfo[pRef->GetRefObjNum()].pos != 0)) { |
813 auto it = pTrailer->begin(); | 826 auto it = pTrailer->begin(); |
814 while (it != pTrailer->end()) { | 827 while (it != pTrailer->end()) { |
815 const CFX_ByteString& key = it->first; | 828 const CFX_ByteString& key = it->first; |
816 CPDF_Object* pElement = it->second; | 829 CPDF_Object* pElement = it->second; |
817 ++it; | 830 ++it; |
818 uint32_t dwObjNum = | 831 uint32_t dwObjNum = |
819 pElement ? pElement->GetObjNum() : 0; | 832 pElement ? pElement->GetObjNum() : 0; |
820 if (dwObjNum) { | 833 if (dwObjNum) { |
821 m_pTrailer->SetReferenceFor(key, m_pDocument, | 834 m_pTrailer->SetReferenceFor(key, m_pDocument, |
822 dwObjNum); | 835 dwObjNum); |
823 } else { | 836 } else { |
824 m_pTrailer->SetFor(key, pElement->Clone()); | 837 m_pTrailer->SetFor(key, pElement->Clone()); |
825 } | 838 } |
826 } | 839 } |
827 } | 840 } |
828 delete pObj; | 841 pObj->Release(); |
829 } else { | 842 } else { |
830 if (pObj->IsStream()) { | 843 if (pObj->IsStream()) { |
831 m_pTrailer = ToDictionary(pTrailer->Clone()); | 844 m_pTrailer = ToDictionary(pTrailer->Clone()); |
832 delete pObj; | 845 pObj->Release(); |
833 } else { | 846 } else { |
834 m_pTrailer = pTrailer; | 847 m_pTrailer = pTrailer; |
835 } | 848 } |
836 | 849 |
837 FX_FILESIZE dwSavePos = m_pSyntax->SavePos(); | 850 FX_FILESIZE dwSavePos = m_pSyntax->SavePos(); |
838 CFX_ByteString strWord = m_pSyntax->GetKeyword(); | 851 CFX_ByteString strWord = m_pSyntax->GetKeyword(); |
839 if (!strWord.Compare("startxref")) { | 852 if (!strWord.Compare("startxref")) { |
840 bool bNumber; | 853 bool bNumber; |
841 CFX_ByteString bsOffset = | 854 CFX_ByteString bsOffset = |
842 m_pSyntax->GetNextWord(&bNumber); | 855 m_pSyntax->GetNextWord(&bNumber); |
843 if (bNumber) | 856 if (bNumber) |
844 m_LastXRefOffset = FXSYS_atoi(bsOffset.c_str()); | 857 m_LastXRefOffset = FXSYS_atoi(bsOffset.c_str()); |
845 } | 858 } |
846 m_pSyntax->RestorePos(dwSavePos); | 859 m_pSyntax->RestorePos(dwSavePos); |
847 } | 860 } |
848 } else { | 861 } else { |
849 delete pObj; | 862 pObj->Release(); |
850 } | 863 } |
851 } | 864 } |
852 } | 865 } |
853 } | 866 } |
854 --i; | 867 --i; |
855 state = ParserState::kDefault; | 868 state = ParserState::kDefault; |
856 } else if (byte == "trailer"[inside_index]) { | 869 } else if (byte == "trailer"[inside_index]) { |
857 inside_index++; | 870 inside_index++; |
858 } else { | 871 } else { |
859 --i; | 872 --i; |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 *pResultPos = m_pSyntax->m_Pos; | 1411 *pResultPos = m_pSyntax->m_Pos; |
1399 | 1412 |
1400 m_pSyntax->RestorePos(SavedPos); | 1413 m_pSyntax->RestorePos(SavedPos); |
1401 return pObj; | 1414 return pObj; |
1402 } | 1415 } |
1403 | 1416 |
1404 CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() { | 1417 CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() { |
1405 if (m_pSyntax->GetKeyword() != "trailer") | 1418 if (m_pSyntax->GetKeyword() != "trailer") |
1406 return nullptr; | 1419 return nullptr; |
1407 | 1420 |
1408 std::unique_ptr<CPDF_Object> pObj( | 1421 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( |
1409 m_pSyntax->GetObject(m_pDocument, 0, 0, true)); | 1422 m_pSyntax->GetObject(m_pDocument, 0, 0, true)); |
1410 if (!ToDictionary(pObj.get())) | 1423 if (!ToDictionary(pObj.get())) |
1411 return nullptr; | 1424 return nullptr; |
1412 return pObj.release()->AsDictionary(); | 1425 return pObj.release()->AsDictionary(); |
1413 } | 1426 } |
1414 | 1427 |
1415 uint32_t CPDF_Parser::GetPermissions() const { | 1428 uint32_t CPDF_Parser::GetPermissions() const { |
1416 if (!m_pSecurityHandler) | 1429 if (!m_pSecurityHandler) |
1417 return 0xFFFFFFFF; | 1430 return 0xFFFFFFFF; |
1418 | 1431 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 m_pLinearized = m_pSyntax->GetObject(nullptr, objnum, gennum, true); | 1463 m_pLinearized = m_pSyntax->GetObject(nullptr, objnum, gennum, true); |
1451 if (!m_pLinearized) | 1464 if (!m_pLinearized) |
1452 return false; | 1465 return false; |
1453 | 1466 |
1454 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 1467 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
1455 if (pDict && pDict->GetObjectFor("Linearized")) { | 1468 if (pDict && pDict->GetObjectFor("Linearized")) { |
1456 m_pSyntax->GetNextWord(nullptr); | 1469 m_pSyntax->GetNextWord(nullptr); |
1457 | 1470 |
1458 CPDF_Object* pLen = pDict->GetObjectFor("L"); | 1471 CPDF_Object* pLen = pDict->GetObjectFor("L"); |
1459 if (!pLen) { | 1472 if (!pLen) { |
1460 delete m_pLinearized; | 1473 m_pLinearized->Release(); |
1461 m_pLinearized = nullptr; | 1474 m_pLinearized = nullptr; |
1462 return false; | 1475 return false; |
1463 } | 1476 } |
1464 | 1477 |
1465 if (pLen->GetInteger() != (int)pFileAccess->GetSize()) | 1478 if (pLen->GetInteger() != (int)pFileAccess->GetSize()) |
1466 return false; | 1479 return false; |
1467 | 1480 |
1468 if (CPDF_Number* pNo = ToNumber(pDict->GetObjectFor("P"))) | 1481 if (CPDF_Number* pNo = ToNumber(pDict->GetObjectFor("P"))) |
1469 m_dwFirstPageNo = pNo->GetInteger(); | 1482 m_dwFirstPageNo = pNo->GetInteger(); |
1470 | 1483 |
1471 if (CPDF_Number* pTable = ToNumber(pDict->GetObjectFor("T"))) | 1484 if (CPDF_Number* pTable = ToNumber(pDict->GetObjectFor("T"))) |
1472 m_LastXRefOffset = pTable->GetInteger(); | 1485 m_LastXRefOffset = pTable->GetInteger(); |
1473 | 1486 |
1474 return true; | 1487 return true; |
1475 } | 1488 } |
1476 delete m_pLinearized; | 1489 m_pLinearized->Release(); |
1477 m_pLinearized = nullptr; | 1490 m_pLinearized = nullptr; |
1478 return false; | 1491 return false; |
1479 } | 1492 } |
1480 | 1493 |
1481 CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( | 1494 CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( |
1482 IFX_SeekableReadStream* pFileAccess, | 1495 IFX_SeekableReadStream* pFileAccess, |
1483 CPDF_Document* pDocument) { | 1496 CPDF_Document* pDocument) { |
1484 ASSERT(!m_bHasParsed); | 1497 ASSERT(!m_bHasParsed); |
1485 | 1498 |
1486 m_bXRefStream = false; | 1499 m_bXRefStream = false; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 return false; | 1588 return false; |
1576 } | 1589 } |
1577 m_ObjectStreamMap.clear(); | 1590 m_ObjectStreamMap.clear(); |
1578 m_bXRefStream = true; | 1591 m_bXRefStream = true; |
1579 return true; | 1592 return true; |
1580 } | 1593 } |
1581 | 1594 |
1582 CPDF_Parser::Error CPDF_Parser::LoadLinearizedMainXRefTable() { | 1595 CPDF_Parser::Error CPDF_Parser::LoadLinearizedMainXRefTable() { |
1583 uint32_t dwSaveMetadataObjnum = m_pSyntax->m_MetadataObjnum; | 1596 uint32_t dwSaveMetadataObjnum = m_pSyntax->m_MetadataObjnum; |
1584 m_pSyntax->m_MetadataObjnum = 0; | 1597 m_pSyntax->m_MetadataObjnum = 0; |
| 1598 if (m_pTrailer) { |
| 1599 m_pTrailer->Release(); |
| 1600 m_pTrailer = nullptr; |
| 1601 } |
1585 | 1602 |
1586 delete m_pTrailer; | |
1587 m_pTrailer = nullptr; | |
1588 m_pSyntax->RestorePos(m_LastXRefOffset - m_pSyntax->m_HeaderOffset); | 1603 m_pSyntax->RestorePos(m_LastXRefOffset - m_pSyntax->m_HeaderOffset); |
1589 | |
1590 uint8_t ch = 0; | 1604 uint8_t ch = 0; |
1591 uint32_t dwCount = 0; | 1605 uint32_t dwCount = 0; |
1592 m_pSyntax->GetNextChar(ch); | 1606 m_pSyntax->GetNextChar(ch); |
1593 while (PDFCharIsWhitespace(ch)) { | 1607 while (PDFCharIsWhitespace(ch)) { |
1594 ++dwCount; | 1608 ++dwCount; |
1595 if (m_pSyntax->m_FileLen >= | 1609 if (m_pSyntax->m_FileLen >= |
1596 (FX_FILESIZE)(m_pSyntax->SavePos() + m_pSyntax->m_HeaderOffset)) { | 1610 (FX_FILESIZE)(m_pSyntax->SavePos() + m_pSyntax->m_HeaderOffset)) { |
1597 break; | 1611 break; |
1598 } | 1612 } |
1599 m_pSyntax->GetNextChar(ch); | 1613 m_pSyntax->GetNextChar(ch); |
1600 } | 1614 } |
1601 m_LastXRefOffset += dwCount; | 1615 m_LastXRefOffset += dwCount; |
1602 m_ObjectStreamMap.clear(); | 1616 m_ObjectStreamMap.clear(); |
1603 m_ObjCache.clear(); | 1617 m_ObjCache.clear(); |
1604 | 1618 |
1605 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && | 1619 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && |
1606 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1620 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
1607 m_LastXRefOffset = 0; | 1621 m_LastXRefOffset = 0; |
1608 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1622 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1609 return FORMAT_ERROR; | 1623 return FORMAT_ERROR; |
1610 } | 1624 } |
1611 | 1625 |
1612 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1626 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1613 return SUCCESS; | 1627 return SUCCESS; |
1614 } | 1628 } |
OLD | NEW |