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

Unified Diff: core/fpdfapi/page/cpdf_streamcontentparser.cpp

Issue 2520953004: Avoid calls to WrapUnique in CPDF_streamparser (Closed)
Patch Set: assign unique_ptr 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 | « no previous file | core/fpdfapi/page/cpdf_streamparser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/page/cpdf_streamcontentparser.cpp
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 8c6038d626b4742e8e7382b6a2a0d9edac70205f..2bc80cc5c94a4442a7fa63dd93b8d3636bb56b1e 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -630,8 +630,8 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
void CPDF_StreamContentParser::Handle_BeginImage() {
FX_FILESIZE savePos = m_pSyntax->GetPos();
- CPDF_Dictionary* pDict =
- new CPDF_Dictionary(m_pDocument->GetByteStringPool());
+ auto pDict =
+ pdfium::MakeUnique<CPDF_Dictionary>(m_pDocument->GetByteStringPool());
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
if (type == CPDF_StreamParser::Keyword) {
@@ -639,7 +639,6 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
m_pSyntax->GetWordSize());
if (bsKeyword != "ID") {
m_pSyntax->SetPos(savePos);
- delete pDict;
return;
}
}
@@ -657,7 +656,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
pDict->SetFor(key, std::move(pObj));
}
}
- ReplaceAbbr(pDict);
+ ReplaceAbbr(pDict.get());
CPDF_Object* pCSObj = nullptr;
if (pDict->KeyExist("ColorSpace")) {
pCSObj = pDict->GetDirectObjectFor("ColorSpace");
@@ -671,9 +670,8 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
}
pDict->SetNewFor<CPDF_Name>("Subtype", "Image");
- std::unique_ptr<CPDF_Stream> pStream(
- m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj));
- bool bGaveDictAway = !!pStream;
+ std::unique_ptr<CPDF_Stream> pStream =
+ m_pSyntax->ReadInlineStream(m_pDocument, std::move(pDict), pCSObj);
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
if (type == CPDF_StreamParser::EndOfData) {
@@ -687,9 +685,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
break;
}
}
- CPDF_ImageObject* pImgObj = AddImage(std::move(pStream));
- if (!pImgObj && !bGaveDictAway)
- delete pDict;
+ AddImage(std::move(pStream));
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
« no previous file with comments | « no previous file | core/fpdfapi/page/cpdf_streamparser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698