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

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

Issue 2520133002: Remove some WrapUnique() calls by returing unique_ptrs (Closed)
Patch Set: rebase Created 4 years 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_document.cpp ('k') | testing/libfuzzer/pdf_streamparser_fuzzer.cc » ('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_parser.h" 7 #include "core/fpdfapi/parser/cpdf_parser.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 m_ObjectInfo[offset].type = 255; 1063 m_ObjectInfo[offset].type = 255;
1064 } 1064 }
1065 } 1065 }
1066 } 1066 }
1067 segindex += count; 1067 segindex += count;
1068 } 1068 }
1069 return true; 1069 return true;
1070 } 1070 }
1071 1071
1072 CPDF_Array* CPDF_Parser::GetIDArray() { 1072 CPDF_Array* CPDF_Parser::GetIDArray() {
1073 CPDF_Object* pID = m_pTrailer ? m_pTrailer->GetObjectFor("ID") : nullptr; 1073 if (!m_pTrailer)
1074 return nullptr;
1075
1076 CPDF_Object* pID = m_pTrailer->GetObjectFor("ID");
1074 if (!pID) 1077 if (!pID)
1075 return nullptr; 1078 return nullptr;
1076 1079
1077 if (CPDF_Reference* pRef = pID->AsReference()) { 1080 CPDF_Reference* pRef = pID->AsReference();
1078 pID = ParseIndirectObject(nullptr, pRef->GetRefObjNum()).release(); 1081 if (!pRef)
1079 m_pTrailer->SetFor("ID", pdfium::WrapUnique(pID)); 1082 return ToArray(pID);
1080 } 1083
1084 std::unique_ptr<CPDF_Object> pNewObj =
1085 ParseIndirectObject(nullptr, pRef->GetRefObjNum());
1086 pID = pNewObj.get();
1087 m_pTrailer->SetFor("ID", std::move(pNewObj));
1081 return ToArray(pID); 1088 return ToArray(pID);
1082 } 1089 }
1083 1090
1084 uint32_t CPDF_Parser::GetRootObjNum() { 1091 uint32_t CPDF_Parser::GetRootObjNum() {
1085 CPDF_Reference* pRef = 1092 CPDF_Reference* pRef =
1086 ToReference(m_pTrailer ? m_pTrailer->GetObjectFor("Root") : nullptr); 1093 ToReference(m_pTrailer ? m_pTrailer->GetObjectFor("Root") : nullptr);
1087 return pRef ? pRef->GetRefObjNum() : 0; 1094 return pRef ? pRef->GetRefObjNum() : 0;
1088 } 1095 }
1089 1096
1090 uint32_t CPDF_Parser::GetInfoObjNum() { 1097 uint32_t CPDF_Parser::GetInfoObjNum() {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1578 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1572 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1579 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1573 m_LastXRefOffset = 0; 1580 m_LastXRefOffset = 0;
1574 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1581 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1575 return FORMAT_ERROR; 1582 return FORMAT_ERROR;
1576 } 1583 }
1577 1584
1578 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1585 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1579 return SUCCESS; 1586 return SUCCESS;
1580 } 1587 }
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_document.cpp ('k') | testing/libfuzzer/pdf_streamparser_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698