| Index: core/fpdfapi/page/cpdf_streamcontentparser.cpp
|
| diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
|
| index 7618f8271f2e25d93652081b3d1ce79b650bb8ad..ed6701382c8db3dc3198204c7f9b9b04e5c4b958 100644
|
| --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
|
| +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
|
| @@ -180,8 +180,12 @@
|
| 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 @@
|
| 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::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 @@
|
| m_pSyntax->GetWordSize());
|
| if (bsKeyword != "ID") {
|
| m_pSyntax->SetPos(savePos);
|
| - delete pDict;
|
| + pDict->Release();
|
| return;
|
| }
|
| }
|
| @@ -534,7 +540,8 @@
|
| }
|
| 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 @@
|
| }
|
| }
|
| 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 @@
|
| }
|
| CPDF_ImageObject* pImgObj = AddImage(std::move(pStream));
|
| if (!pImgObj && !bGaveDictAway)
|
| - delete pDict;
|
| + pDict->Release();
|
| }
|
|
|
| void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
|
| @@ -663,10 +669,10 @@
|
| 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 @@
|
| 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;
|
|
|
|
|