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

Unified Diff: core/fpdfapi/parser/cpdf_parser.cpp

Issue 2520133002: Remove some WrapUnique() calls by returing unique_ptrs (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/parser/cpdf_parser.cpp
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 5354417eda857de70bdb4de856e8fa75506e5192..2f432ed9f9c130ecf59354dc157eb548addaf127 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -1070,14 +1070,21 @@ bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) {
}
CPDF_Array* CPDF_Parser::GetIDArray() {
- CPDF_Object* pID = m_pTrailer ? m_pTrailer->GetObjectFor("ID") : nullptr;
+ if (!m_pTrailer)
+ return nullptr;
+
+ CPDF_Object* pID = m_pTrailer->GetObjectFor("ID");
if (!pID)
return nullptr;
- if (CPDF_Reference* pRef = pID->AsReference()) {
- pID = ParseIndirectObject(nullptr, pRef->GetRefObjNum()).release();
- m_pTrailer->SetFor("ID", pdfium::WrapUnique(pID));
- }
+ CPDF_Reference* pRef = pID->AsReference();
+ if (!pRef)
+ return ToArray(pID);
+
+ std::unique_ptr<CPDF_Object> pNewObj =
+ ParseIndirectObject(nullptr, pRef->GetRefObjNum());
+ pID = pNewObj.get();
+ m_pTrailer->SetFor("ID", std::move(pNewObj));
return ToArray(pID);
}
« 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