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

Unified Diff: fpdfsdk/formfiller/cba_fontmap.cpp

Issue 2520493002: Make CPDF_Stream() take unique_ptr's to its dictionary. (Closed)
Patch Set: rebase, lint, fix new test. 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 | « fpdfsdk/cpdfsdk_baannot.cpp ('k') | fpdfsdk/fpdf_flatten.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/formfiller/cba_fontmap.cpp
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index 83e45791e20f7f7a5a4eaa317be4a840829970f3..750b41627e798fd790977191d05baf03f98b4be8 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());
}
}
« no previous file with comments | « fpdfsdk/cpdfsdk_baannot.cpp ('k') | fpdfsdk/fpdf_flatten.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698