From 9e05ee1e7bfb74d56d69620ad1e72b03e29b9237 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 21 Nov 2016 13:19:10 -0800 Subject: Make CPDF_Stream() take unique_ptr's to its dictionary. Review-Url: https://codereview.chromium.org/2520493002 --- fpdfsdk/cpdfsdk_baannot.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'fpdfsdk/cpdfsdk_baannot.cpp') diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp index 9fb1e88a84..3eedf1502c 100644 --- a/fpdfsdk/cpdfsdk_baannot.cpp +++ b/fpdfsdk/cpdfsdk_baannot.cpp @@ -7,6 +7,7 @@ #include "fpdfsdk/cpdfsdk_baannot.h" #include +#include #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_document.h" @@ -323,19 +324,16 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, CPDF_Dictionary* pStreamDict = pStream->GetDict(); if (!pStreamDict) { - pStreamDict = - new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool()); + auto pNewDict = pdfium::MakeUnique( + m_pAnnot->GetDocument()->GetByteStringPool()); + pStreamDict = pNewDict.get(); pStreamDict->SetNewFor("Type", "XObject"); pStreamDict->SetNewFor("Subtype", "Form"); pStreamDict->SetNewFor("FormType", 1); - pStream->InitStream(nullptr, 0, pStreamDict); + pStream->InitStream(nullptr, 0, std::move(pNewDict)); } - - if (pStreamDict) { - pStreamDict->SetMatrixFor("Matrix", matrix); - pStreamDict->SetRectFor("BBox", rcBBox); - } - + pStreamDict->SetMatrixFor("Matrix", matrix); + pStreamDict->SetRectFor("BBox", rcBBox); pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength()); } -- cgit v1.2.3