diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-04-25 16:39:34 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-26 00:05:22 +0000 |
commit | 012ae898a069bda7afbfdad4eb4c8ba042b68dc7 (patch) | |
tree | 9a8e9e05e2fe6fd127b781dbb55b8793eea2d92e /core/fpdfapi/parser | |
parent | 5c42c8e9b78082319ad57f143ad03037d447aa36 (diff) | |
download | pdfium-012ae898a069bda7afbfdad4eb4c8ba042b68dc7.tar.xz |
Get rid of a few |new|s in CPDF_Document.
The chain of destructors may attempt to use m_pDocPage
after it has been set to null by the unique_ptr destructor.
Verify it is still present before using it from any code
that may be called from some other CPDF_ destructor.
Change-Id: I007160231d73feed85d90efc687d6da993653f96
Reviewed-on: https://pdfium-review.googlesource.com/4499
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/cpdf_document.cpp | 5 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_document.h | 5 |
2 files changed, 4 insertions, 6 deletions
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index c23637e8fa..48791262ea 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -348,14 +348,13 @@ CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser) m_bLinearized(false), m_iFirstPageNo(0), m_dwFirstPageObjNum(0), - m_pDocPage(new CPDF_DocPageData(this)), - m_pDocRender(new CPDF_DocRenderData(this)) { + m_pDocPage(pdfium::MakeUnique<CPDF_DocPageData>(this)), + m_pDocRender(pdfium::MakeUnique<CPDF_DocRenderData>(this)) { if (pParser) SetLastObjNum(m_pParser->GetLastObjNum()); } CPDF_Document::~CPDF_Document() { - delete m_pDocPage; CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); } diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h index 8d3525419f..2f54ba7c28 100644 --- a/core/fpdfapi/parser/cpdf_document.h +++ b/core/fpdfapi/parser/cpdf_document.h @@ -58,7 +58,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder { CPDF_Dictionary* GetPage(int iPage); int GetPageIndex(uint32_t objnum); uint32_t GetUserPermissions() const; - CPDF_DocPageData* GetPageData() const { return m_pDocPage; } + CPDF_DocPageData* GetPageData() const { return m_pDocPage.get(); } void SetPageObjNum(int iPage, uint32_t objNum); @@ -142,8 +142,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder { bool m_bLinearized; int m_iFirstPageNo; uint32_t m_dwFirstPageObjNum; - // TODO(thestig): Figure out why this cannot be a std::unique_ptr. - CPDF_DocPageData* m_pDocPage; + std::unique_ptr<CPDF_DocPageData> m_pDocPage; std::unique_ptr<CPDF_DocRenderData> m_pDocRender; std::unique_ptr<JBig2_DocumentContext> m_pCodecContext; std::unique_ptr<CPDF_LinkList> m_pLinksContext; |