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

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

Issue 2475823002: Assert objnum non-zero in ReplaceIndirectObjectIfHigherGeneration() (Closed)
Patch Set: nit 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_indirect_object_holder.cpp ('k') | no next file » | 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_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
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
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 }
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_indirect_object_holder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698