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 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 m_SortedOffset.insert(last_trailer - m_pSyntax->m_HeaderOffset); | 953 m_SortedOffset.insert(last_trailer - m_pSyntax->m_HeaderOffset); |
954 return m_pTrailer && !m_ObjectInfo.empty(); | 954 return m_pTrailer && !m_ObjectInfo.empty(); |
955 } | 955 } |
956 | 956 |
957 bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) { | 957 bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) { |
958 std::unique_ptr<CPDF_Object> pObject( | 958 std::unique_ptr<CPDF_Object> pObject( |
959 ParseIndirectObjectAt(m_pDocument, *pos, 0)); | 959 ParseIndirectObjectAt(m_pDocument, *pos, 0)); |
960 if (!pObject) | 960 if (!pObject) |
961 return false; | 961 return false; |
962 | 962 |
| 963 uint32_t objnum = pObject->m_ObjNum; |
| 964 if (!objnum) |
| 965 return false; |
| 966 |
963 CPDF_Object* pUnownedObject = pObject.get(); | 967 CPDF_Object* pUnownedObject = pObject.get(); |
964 | |
965 if (m_pDocument) { | 968 if (m_pDocument) { |
966 CPDF_Dictionary* pRootDict = m_pDocument->GetRoot(); | 969 CPDF_Dictionary* pRootDict = m_pDocument->GetRoot(); |
967 if (pRootDict && pRootDict->GetObjNum() == pObject->m_ObjNum) | 970 if (pRootDict && pRootDict->GetObjNum() == objnum) |
968 return false; | 971 return false; |
969 // Takes ownership of object (std::move someday). | 972 // Takes ownership of object (std::move someday). |
970 uint32_t objnum = pObject->m_ObjNum; | |
971 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration( | 973 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration( |
972 objnum, pObject.release())) { | 974 objnum, pObject.release())) { |
973 return false; | 975 return false; |
974 } | 976 } |
975 } | 977 } |
976 | 978 |
977 CPDF_Stream* pStream = pUnownedObject->AsStream(); | 979 CPDF_Stream* pStream = pUnownedObject->AsStream(); |
978 if (!pStream) | 980 if (!pStream) |
979 return false; | 981 return false; |
980 | 982 |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && | 1621 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && |
1620 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1622 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
1621 m_LastXRefOffset = 0; | 1623 m_LastXRefOffset = 0; |
1622 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1624 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1623 return FORMAT_ERROR; | 1625 return FORMAT_ERROR; |
1624 } | 1626 } |
1625 | 1627 |
1626 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1628 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1627 return SUCCESS; | 1629 return SUCCESS; |
1628 } | 1630 } |
OLD | NEW |