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

Side by Side Diff: core/fpdfapi/page/cpdf_streamcontentparser.cpp

Issue 2420743002: Make CPDF_Image() constructors saner. (Closed)
Patch Set: Fix leak Created 4 years, 2 months 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
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/page/cpdf_streamcontentparser.h" 7 #include "core/fpdfapi/page/cpdf_streamcontentparser.h"
8 8
9 #include "core/fpdfapi/font/cpdf_font.h" 9 #include "core/fpdfapi/font/cpdf_font.h"
10 #include "core/fpdfapi/font/cpdf_type3font.h" 10 #include "core/fpdfapi/font/cpdf_type3font.h"
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 SetGraphicStates(pFormObj.get(), true, true, true); 699 SetGraphicStates(pFormObj.get(), true, true, true);
700 m_pObjectHolder->GetPageObjectList()->push_back(std::move(pFormObj)); 700 m_pObjectHolder->GetPageObjectList()->push_back(std::move(pFormObj));
701 } 701 }
702 702
703 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(UniqueStream pStream) { 703 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(UniqueStream pStream) {
704 if (!pStream) 704 if (!pStream)
705 return nullptr; 705 return nullptr;
706 706
707 auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>(); 707 auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>();
708 pImageObj->SetOwnedImage( 708 pImageObj->SetOwnedImage(
709 pdfium::MakeUnique<CPDF_Image>(m_pDocument, pStream.release(), true)); 709 pdfium::MakeUnique<CPDF_Image>(m_pDocument, std::move(pStream)));
710
711 return AddImageObject(std::move(pImageObj)); 710 return AddImageObject(std::move(pImageObj));
712 } 711 }
713 712
714 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(uint32_t streamObjNum) { 713 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(uint32_t streamObjNum) {
715 CPDF_Stream* pStream = ToStream(m_pDocument->GetIndirectObject(streamObjNum)); 714 CPDF_Stream* pStream = ToStream(m_pDocument->GetIndirectObject(streamObjNum));
716 if (!pStream) 715 if (!pStream)
717 return nullptr; 716 return nullptr;
718 717
719 auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>(); 718 auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>();
720 pImageObj->SetUnownedImage(m_pDocument->LoadImageF(pStream)); 719 pImageObj->SetUnownedImage(m_pDocument->LoadImageF(pStream));
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 } 1551 }
1553 default: 1552 default:
1554 bProcessed = FALSE; 1553 bProcessed = FALSE;
1555 } 1554 }
1556 if (!bProcessed) { 1555 if (!bProcessed) {
1557 m_pSyntax->SetPos(last_pos); 1556 m_pSyntax->SetPos(last_pos);
1558 return; 1557 return;
1559 } 1558 }
1560 } 1559 }
1561 } 1560 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698