diff options
author | tsepez <tsepez@chromium.org> | 2016-11-21 13:19:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-21 13:19:10 -0800 |
commit | 9e05ee1e7bfb74d56d69620ad1e72b03e29b9237 (patch) | |
tree | 12b47b617d99edc7bd2715292402b74e864e1fa4 /fpdfsdk/formfiller/cba_fontmap.cpp | |
parent | aa3922dd713d480229408f3a0813b7dab9e8fd78 (diff) | |
download | pdfium-9e05ee1e7bfb74d56d69620ad1e72b03e29b9237.tar.xz |
Make CPDF_Stream() take unique_ptr's to its dictionary.
Review-Url: https://codereview.chromium.org/2520493002
Diffstat (limited to 'fpdfsdk/formfiller/cba_fontmap.cpp')
-rw-r--r-- | fpdfsdk/formfiller/cba_fontmap.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp index 83e45791e2..750b41627e 100644 --- a/fpdfsdk/formfiller/cba_fontmap.cpp +++ b/fpdfsdk/formfiller/cba_fontmap.cpp @@ -6,6 +6,8 @@ #include "fpdfsdk/formfiller/cba_fontmap.h" +#include <utility> + #include "core/fpdfapi/font/cpdf_font.h" #include "core/fpdfapi/page/cpdf_page.h" #include "core/fpdfapi/parser/cpdf_document.h" @@ -171,24 +173,24 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, CPDF_Dictionary* pStreamDict = pStream->GetDict(); if (!pStreamDict) { - pStreamDict = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); - pStream->InitStream(nullptr, 0, pStreamDict); + auto pOwnedDict = + pdfium::MakeUnique<CPDF_Dictionary>(m_pDocument->GetByteStringPool()); + pStreamDict = pOwnedDict.get(); + pStream->InitStream(nullptr, 0, std::move(pOwnedDict)); } - if (pStreamDict) { - CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); - if (!pStreamResList) - pStreamResList = pStreamDict->SetNewFor<CPDF_Dictionary>("Resources"); - CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font"); - if (!pStreamResFontList) { - pStreamResFontList = m_pDocument->NewIndirect<CPDF_Dictionary>(); - pStreamResList->SetNewFor<CPDF_Reference>( - "Font", m_pDocument, pStreamResFontList->GetObjNum()); - } - if (!pStreamResFontList->KeyExist(sAlias)) { - pStreamResFontList->SetNewFor<CPDF_Reference>( - sAlias, m_pDocument, pFont->GetFontDict()->GetObjNum()); - } + CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); + if (!pStreamResList) + pStreamResList = pStreamDict->SetNewFor<CPDF_Dictionary>("Resources"); + CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font"); + if (!pStreamResFontList) { + pStreamResFontList = m_pDocument->NewIndirect<CPDF_Dictionary>(); + pStreamResList->SetNewFor<CPDF_Reference>("Font", m_pDocument, + pStreamResFontList->GetObjNum()); + } + if (!pStreamResFontList->KeyExist(sAlias)) { + pStreamResFontList->SetNewFor<CPDF_Reference>( + sAlias, m_pDocument, pFont->GetFontDict()->GetObjNum()); } } |