diff options
author | dsinclair <dsinclair@chromium.org> | 2016-11-04 08:25:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-04 08:25:34 -0700 |
commit | f0d5b6c35fa343108a3ab7a25bc2cc2b3cf105b3 (patch) | |
tree | edc3d5f35225971679e581c8ef951de8275a944b /core/fpdfapi/page/cpdf_streamcontentparser.cpp | |
parent | 4de3d095c9d9e961f93750cf1ebd489fd515be12 (diff) | |
download | pdfium-f0d5b6c35fa343108a3ab7a25bc2cc2b3cf105b3.tar.xz |
Revert of Remove CPDF_Object::Release() in favor of direct delete (patchset #11 id:200001 of https://codereview.chromium.org/2384883003/ )
Reason for revert:
Looks like it's blocking the roll.
https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_compile_dbg_ng/builds/186619
Original issue's description:
> Remove CPDF_Object::Release() in favor of direct delete
>
> Follow-on once we prove Release always deletes in previous CL.
>
> Committed: https://pdfium.googlesource.com/pdfium/+/4de3d095c9d9e961f93750cf1ebd489fd515be12
TBR=thestig@chromium.org,tsepez@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review-Url: https://codereview.chromium.org/2478253002
Diffstat (limited to 'core/fpdfapi/page/cpdf_streamcontentparser.cpp')
-rw-r--r-- | core/fpdfapi/page/cpdf_streamcontentparser.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 7618f8271f..ed6701382c 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -180,8 +180,12 @@ CPDF_StreamContentParser::CPDF_StreamContentParser( CPDF_StreamContentParser::~CPDF_StreamContentParser() { ClearAllParams(); FX_Free(m_pPathPoints); - delete m_pLastImageDict; - delete m_pLastCloneImageDict; + if (m_pLastImageDict) { + m_pLastImageDict->Release(); + } + if (m_pLastCloneImageDict) { + m_pLastCloneImageDict->Release(); + } } int CPDF_StreamContentParser::GetNextParamPos() { @@ -190,9 +194,10 @@ int CPDF_StreamContentParser::GetNextParamPos() { if (m_ParamStartPos == kParamBufSize) { m_ParamStartPos = 0; } - if (m_ParamBuf[m_ParamStartPos].m_Type == 0) - delete m_ParamBuf[m_ParamStartPos].m_pObject; - + if (m_ParamBuf[m_ParamStartPos].m_Type == 0) { + if (CPDF_Object* pObject = m_ParamBuf[m_ParamStartPos].m_pObject) + pObject->Release(); + } return m_ParamStartPos; } int index = m_ParamStartPos + m_ParamCount; @@ -239,9 +244,10 @@ void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) { void CPDF_StreamContentParser::ClearAllParams() { uint32_t index = m_ParamStartPos; for (uint32_t i = 0; i < m_ParamCount; i++) { - if (m_ParamBuf[index].m_Type == 0) - delete m_ParamBuf[index].m_pObject; - + if (m_ParamBuf[index].m_Type == 0) { + if (CPDF_Object* pObject = m_ParamBuf[index].m_pObject) + pObject->Release(); + } index++; if (index == kParamBufSize) { index = 0; @@ -525,7 +531,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { m_pSyntax->GetWordSize()); if (bsKeyword != "ID") { m_pSyntax->SetPos(savePos); - delete pDict; + pDict->Release(); return; } } @@ -534,7 +540,8 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1, m_pSyntax->GetWordSize() - 1); - std::unique_ptr<CPDF_Object> pObj(m_pSyntax->ReadNextObject(false, 0)); + std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( + m_pSyntax->ReadNextObject(false, 0)); if (!key.IsEmpty()) { uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0; if (dwObjNum) @@ -559,8 +566,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } } pDict->SetNameFor("Subtype", "Image"); - std::unique_ptr<CPDF_Stream> pStream( - m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj)); + UniqueStream pStream(m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj)); bool bGaveDictAway = !!pStream; while (1) { CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement(); @@ -577,7 +583,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } CPDF_ImageObject* pImgObj = AddImage(std::move(pStream)); if (!pImgObj && !bGaveDictAway) - delete pDict; + pDict->Release(); } void CPDF_StreamContentParser::Handle_BeginMarkedContent() { @@ -663,10 +669,10 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { type = pXObject->GetDict()->GetStringFor("Subtype"); if (type == "Image") { - CPDF_ImageObject* pObj = pXObject->IsInline() - ? AddImage(std::unique_ptr<CPDF_Stream>( - ToStream(pXObject->Clone()))) - : AddImage(pXObject->GetObjNum()); + CPDF_ImageObject* pObj = + pXObject->IsInline() + ? AddImage(UniqueStream(ToStream(pXObject->Clone()))) + : AddImage(pXObject->GetObjNum()); m_LastImageName = name; m_pLastImage = pObj->GetImage(); @@ -698,8 +704,7 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { m_pObjectHolder->GetPageObjectList()->push_back(std::move(pFormObj)); } -CPDF_ImageObject* CPDF_StreamContentParser::AddImage( - std::unique_ptr<CPDF_Stream> pStream) { +CPDF_ImageObject* CPDF_StreamContentParser::AddImage(UniqueStream pStream) { if (!pStream) return nullptr; |